orm: offset test

pull/5532/head
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 select from User limit 2
} }
assert two_users.len == 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 { struct User {

View File

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