diff --git a/vlib/orm/orm_test.v b/vlib/orm/orm_test.v index 787d707c03..88f685cc38 100644 --- a/vlib/orm/orm_test.v +++ b/vlib/orm/orm_test.v @@ -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() { diff --git a/vlib/v/gen/sql.v b/vlib/v/gen/sql.v index 415beb8677..2f514c23b9 100644 --- a/vlib/v/gen/sql.v +++ b/vlib/v/gen/sql.v @@ -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('"));')