Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C error when asserting value from sql db { select from...} #23345

Open
islonely opened this issue Jan 2, 2025 · 0 comments
Open

C error when asserting value from sql db { select from...} #23345

islonely opened this issue Jan 2, 2025 · 0 comments
Labels
ORM Bugs/feature requests, that are related to the V ORM.

Comments

@islonely
Copy link
Contributor

islonely commented Jan 2, 2025

V doctor:

V full version: V 0.4.9 4225a34.b79257b
OS: macos, macOS, 15.1.1, 24B91
Processor: 8 cpus, 64bit, little endian, Apple M3

getwd: /Users/adamoates/.vmodules/islonely/hex
vexe: /Users/adamoates/v/v
vexe mtime: 2025-01-02 15:24:10

vroot: OK, value: /Users/adamoates/v
VMODULES: OK, value: /Users/adamoates/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.39.5 (Apple Git-154)
Git vroot status: weekly.2024.53-14-gb79257b7
.git/config present: true

CC version: Apple clang version 16.0.0 (clang-1600.0.26.4)
emcc version: N/A
thirdparty/tcc status: thirdparty-macos-arm64 713692d4

What did you do?
./v -g -o vdbg cmd/v && ./vdbg /Users/adamoates/Documents/test.v && /Users/adamoates/Documents/test

import db.sqlite

struct Parent {
	id       int     @[primary; sql: serial]
	children []Child @[fkey: 'parent_id']
}

struct Child {
	id        int @[primary; sql: serial]
	parent_id int
}

fn main() {
	mut db := sqlite.connect(':memory:')!
	parent := Parent{
		children: [Child{}, Child{}]
	}
	sql db {
		create table Child
		create table Parent
		insert parent into Parent
	}!

	assert parent.children.len == (sql db {
		select from Parent limit 1
	}!)[0].children.len
}

What did you see?

================== C compilation error (from cc): ==============
cc: /tmp/v_501/test.01JGKTRGKDXEAZ1P41CDN12J0G.tmp.c:10526:108: error: use of undeclared identifier '_t25'
cc:  10526 |                 v_assert_meta_info__t23.rvalue = string_clone(int_str((*(main__Parent*)array_get(( *(Array_main__Parent*)_t25.data), 0)).children.len));
cc:        |                                                                                                                          ^
cc: 1 error generated.
================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

What did you expect to see?

Expected code to compile and the assert to be reached as true.

Huly®: V_0.6-21776

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@felipensp felipensp added the ORM Bugs/feature requests, that are related to the V ORM. label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ORM Bugs/feature requests, that are related to the V ORM.
Projects
None yet
Development

No branches or pull requests

2 participants