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

orm: offset test

This commit is contained in:
Alexander Medvednikov 2020-06-27 16:25:25 +02:00
parent f990a0b3d3
commit 3672cfad0b
2 changed files with 8 additions and 3 deletions

View File

@ -173,7 +173,13 @@ fn test_orm_sqlite() {
select from User limit 2
}
assert two_users.len == 2
assert two_users[0].id > 0
assert two_users[0].id == 1
//
y := sql db {
select from User limit 2 offset 1
}
assert y.len == 2
assert y[0].id == 2
}
struct User {

View File

@ -53,8 +53,7 @@ fn (mut p Parser) sql_expr() ast.Expr {
limit_expr = p.expr(0)
}
if p.tok.kind == .name && p.tok.lit == 'offset' {
// `limit 1` means that a single object is returned
p.check_name() // `limit`
p.check_name() // `offset`
has_offset = true
offset_expr = p.expr(0)
}