mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: keep order by in orm blocks (#7576)
This commit is contained in:
parent
dfcbf31f65
commit
f707e13b3f
@ -1028,6 +1028,13 @@ pub fn (mut f Fmt) expr(node ast.Expr) {
|
|||||||
f.write(' where ')
|
f.write(' where ')
|
||||||
f.expr(node.where_expr)
|
f.expr(node.where_expr)
|
||||||
}
|
}
|
||||||
|
if node.has_order {
|
||||||
|
f.write(' order by ')
|
||||||
|
f.expr(node.order_expr)
|
||||||
|
if node.has_desc {
|
||||||
|
f.write(' desc')
|
||||||
|
}
|
||||||
|
}
|
||||||
if node.has_limit {
|
if node.has_limit {
|
||||||
f.write(' limit ')
|
f.write(' limit ')
|
||||||
f.expr(node.limit_expr)
|
f.expr(node.limit_expr)
|
||||||
|
@ -33,6 +33,12 @@ fn main() {
|
|||||||
customer := sql db {
|
customer := sql db {
|
||||||
select from Customer where id == 1 limit 1
|
select from Customer where id == 1 limit 1
|
||||||
}
|
}
|
||||||
|
best_customer := sql db {
|
||||||
|
select from Customer order by nr_orders desc limit 1
|
||||||
|
}
|
||||||
|
second_best := sql db {
|
||||||
|
select from UCustomerser order by nr_orders desc limit 1 offset 1
|
||||||
|
}
|
||||||
println('$customer.id - $customer.name')
|
println('$customer.id - $customer.name')
|
||||||
// insert a new customer
|
// insert a new customer
|
||||||
new_customer := Customer{
|
new_customer := Customer{
|
||||||
|
Loading…
Reference in New Issue
Block a user