You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cgen errors and a V panic is produced when trying to insert/select a struct with anonymous struct children.
Reproduction Steps
This does the cgen error.
importdb.sqlitefnmain() {
mutdb:= sqlite.connect(':memory:')!
sql db {
create table Foo
}!foo:= Foo {
name: struct{
first: "John",
last: "Smith"
}
}
sql db {
insert foo into Foo
}!foos:= sql db {
select from Foo
} or {
[]Foo{}
}
println(foo)
println(foos)
}
structFoo {
id int @[primary; serial]
name struct {
first string
last string
}
}
This does the V panic.
importdb.sqlitefnmain() {
mutdb:= sqlite.connect(':memory:')!
sql db {
create table Foo
}!foo:= Foo {
name: struct{
first: "John",
last: "Smith"
}
}
sql db {
insert foo into Foo
}!foos:= sql db {
select from Foo
} or {
[]Foo{}
}
println(foo)
println(foos)
}
structFoo {
id int @[primary; serial]
name struct {
id int @[primary; serial]
// ^ THIS LINE FIXED THE CGEN ERROR
first string
last string
}
}
Expected Behavior
Expected a V error letting me know I cannot use anonymous structs or to use @[skip] on the anonymous struct field.
Current Behavior
For the first example in reproduction steps:
cgen error: field "id" does not exist on "main._VAnonStruct1"
For the second:
V panic: result not set (no such table: _VAnonStruct1 (1) (INSERT INTO `_VAnonStruct1` (`first`, `last`) VALUES (?1, ?2);))
v hash: b487986
0 test 0x0000000102a838b0 panic_result_not_set + 124
1 test 0x0000000102a98294 main__main + 1308
2 test 0x0000000102a99414 main + 84
3 dyld 0x000000019c020274 start + 2840
Possible Solution
Make the ORM create a table for anonymous structs when sql db { create table Foo } is used.
Additional Information/Context
No response
V version
V 0.4.9 2911f29.b487986
Environment details (OS name and version, etc.)
V full version: V 0.4.9 2911f29.b487986
OS: macos, macOS, 15.1.1, 24B91
Processor: 8 cpus, 64bit, little endian, Apple M3
getwd: /Users/adamoates/Documents/shattlebip
vexe: /Users/adamoates/v/v
vexe mtime: 2024-12-28 17:47:59
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: 0.4.9-40-gb487986b
.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
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.
Describe the bug
cgen errors and a V panic is produced when trying to insert/select a struct with anonymous struct children.
Reproduction Steps
This does the cgen error.
This does the V panic.
Expected Behavior
Expected a V error letting me know I cannot use anonymous structs or to use
@[skip]
on the anonymous struct field.Current Behavior
For the first example in reproduction steps:
For the second:
Possible Solution
Make the ORM create a table for anonymous structs when
sql db { create table Foo }
is used.Additional Information/Context
No response
V version
V 0.4.9 2911f29.b487986
Environment details (OS name and version, etc.)
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.
Huly®: V_0.6-21731
The text was updated successfully, but these errors were encountered: