v
v copied to clipboard
orm: init or implementation
This PR adds or to the orm:
import sqlite
struct Foo {
id int [primary; sql: serial]
}
fn main() {
db := sqlite.connect(':memory:') ?
mut foo := Foo{}
sql db {
insert foo into Foo
} or {
eprintln(err)
}
res := sql db {
select from Foo
} or {
[]Foo{}
}
eprintln(res)
}
TODO:
- [x] Add checker tests
- [x] Add general tests for or expr
FAIL [ 155/1035] 454.691 ms vlib/orm/orm_test.v
================ V panic ================
module: builtin
function: slice()
message: array.slice: invalid slice index (0 > -1)
file: /home/runner/work/v/v/vlib/builtin/array.v:485
v hash: f468883
I'll convert it do a draft anyways
Thanks @spytheman didn't knew exactly the or things
FAIL [ 156/1038] 6280.150 ms vlib/orm/orm_sql_or_blocks_test.v
[/home/runner/work/v/v/vlib/v/gen/c/sql.v:782] g.inside_call: false
[/home/runner/work/v/v/vlib/v/gen/c/sql.v:782] g.inside_call: false
[/home/runner/work/v/v/vlib/v/gen/c/sql.v:782] g.inside_call: false
Uninitialized bytes in __interceptor_strlen at offset 31 inside [0x703000000578, 32)
==17656==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7f41c9905c3a (/lib/x86_64-linux-gnu/libsqlite3.so.0+0x44c3a)
#1 0x7f41c993de4b (/lib/x86_64-linux-gnu/libsqlite3.so.0+0x7ce4b)
#2 0x7f41c99aa10b (/lib/x86_64-linux-gnu/libsqlite3.so.0+0xe910b)
#3 0x7aaee4 in sqlite__connect (/tmp/v/test_session_124359337987/orm_sql_or_blocks_test+0x7aaee4)
#4 0x7b0630 in main__test_ensure_db_exists_and_user_table_is_ok (/tmp/v/test_session_124359337987/orm_sql_or_blocks_test+0x7b0630)
#5 0x7c35ac in main (/tmp/v/test_session_124359337987/orm_sql_or_blocks_test+0x7c35ac)
#6 0x7f41c9554082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:[308](https://github.com/vlang/v/runs/7267602782?check_suite_focus=true#step:7:309):16
#7 0x41d64d in _start (/tmp/v/test_session_124359337987/orm_sql_or_blocks_test+0x41d64d)
Will continue this pr after the 1th August probably, bc of holidays
Friendly Ping?