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

orm: fix offset when order is given too (#5625)

This commit is contained in:
Louis Schmieder 2020-07-02 22:22:52 +02:00 committed by GitHub
parent 5813d2bf72
commit 421b6d4a80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -202,6 +202,13 @@ fn test_orm_sqlite() {
select from User order age desc limit 1
}
assert oldest.age == 34
offs := 1
second_oldest := sql db {
select from User order age desc limit 1 offset offs
}
assert second_oldest.age == 31
}
fn test_orm_pg() {

View File

@ -149,6 +149,7 @@ fn (mut g Gen) sql_select_expr(node ast.SqlExpr) {
}
if node.has_offset {
g.write(' OFFSET ')
g.sql_side = .right
g.expr_to_sql(node.offset_expr)
}
g.writeln('"));')