1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: allow using struct field as ORM limit and offset. (#17330)

This commit is contained in:
walking devel
2023-02-15 17:47:35 +00:00
committed by GitHub
parent f5423ed26b
commit 5d4c9dc9fc
2 changed files with 31 additions and 0 deletions

View File

@ -34,6 +34,33 @@ struct TestTime {
create time.Time
}
fn test_use_struct_field_as_limit() {
db := sqlite.connect(':memory:') or { panic(err) }
sql db {
create table User
}
foo := Foo{
age: 10
}
sam := User{
age: 29
name: 'Sam'
}
sql db {
insert sam into User
}
users := sql db {
select from User limit foo.age
}
assert users.len == 1
}
fn test_orm() {
db := sqlite.connect(':memory:') or { panic(err) }