orm: fix offset when order is given too (#5625)
parent
5813d2bf72
commit
421b6d4a80
|
@ -202,6 +202,13 @@ fn test_orm_sqlite() {
|
||||||
select from User order age desc limit 1
|
select from User order age desc limit 1
|
||||||
}
|
}
|
||||||
assert oldest.age == 34
|
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() {
|
fn test_orm_pg() {
|
||||||
|
|
|
@ -149,6 +149,7 @@ fn (mut g Gen) sql_select_expr(node ast.SqlExpr) {
|
||||||
}
|
}
|
||||||
if node.has_offset {
|
if node.has_offset {
|
||||||
g.write(' OFFSET ')
|
g.write(' OFFSET ')
|
||||||
|
g.sql_side = .right
|
||||||
g.expr_to_sql(node.offset_expr)
|
g.expr_to_sql(node.offset_expr)
|
||||||
}
|
}
|
||||||
g.writeln('"));')
|
g.writeln('"));')
|
||||||
|
|
Loading…
Reference in New Issue