mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
orm: offset
This commit is contained in:
parent
f073ffa4ad
commit
f990a0b3d3
@ -136,6 +136,10 @@ fn (mut g Gen) sql_select_expr(node ast.SqlExpr) {
|
||||
g.write(' limit ')
|
||||
g.expr_to_sql(node.limit_expr)
|
||||
}
|
||||
if node.has_offset {
|
||||
g.write(' offset ')
|
||||
g.expr_to_sql(node.offset_expr)
|
||||
}
|
||||
g.writeln('"));')
|
||||
// Dump all sql parameters generated by our custom expr handler
|
||||
binds := g.sql_buf.str()
|
||||
|
@ -40,6 +40,8 @@ fn (mut p Parser) sql_expr() ast.Expr {
|
||||
}
|
||||
mut has_limit := false
|
||||
mut limit_expr := ast.Expr{}
|
||||
mut has_offset := false
|
||||
mut offset_expr := ast.Expr{}
|
||||
if p.tok.kind == .name && p.tok.lit == 'limit' {
|
||||
// `limit 1` means that a single object is returned
|
||||
p.check_name() // `limit`
|
||||
@ -50,6 +52,12 @@ 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`
|
||||
has_offset = true
|
||||
offset_expr = p.expr(0)
|
||||
}
|
||||
if !query_one && !is_count {
|
||||
// return an array
|
||||
typ = table.new_type(p.table.find_or_register_array(table_type, 1, p.mod))
|
||||
@ -69,6 +77,8 @@ fn (mut p Parser) sql_expr() ast.Expr {
|
||||
has_where: has_where
|
||||
has_limit: has_limit
|
||||
limit_expr: limit_expr
|
||||
has_offset: has_offset
|
||||
offset_expr: offset_expr
|
||||
is_array: !query_one
|
||||
pos: pos
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user