fmt: smarter wrap of orm lines (#7070)
parent
7c394b9d58
commit
dedb8f7e41
|
@ -465,6 +465,7 @@ pub fn (mut f Fmt) stmt(node ast.Stmt) {
|
||||||
} else {
|
} else {
|
||||||
f.write(' ')
|
f.write(' ')
|
||||||
}
|
}
|
||||||
|
f.wrap_long_line(2, true)
|
||||||
}
|
}
|
||||||
f.write('where ')
|
f.write('where ')
|
||||||
f.expr(node.where_expr)
|
f.expr(node.where_expr)
|
||||||
|
@ -1110,8 +1111,8 @@ pub fn (mut f Fmt) expr(node ast.Expr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut f Fmt) wrap_long_line(penalty int, add_indent bool) bool {
|
pub fn (mut f Fmt) wrap_long_line(penalty_idx int, add_indent bool) bool {
|
||||||
if f.line_len <= max_len[penalty] {
|
if f.line_len <= max_len[penalty_idx] {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if f.out.buf[f.out.buf.len - 1] == ` ` {
|
if f.out.buf[f.out.buf.len - 1] == ` ` {
|
||||||
|
|
|
@ -46,4 +46,8 @@ fn main() {
|
||||||
sql db {
|
sql db {
|
||||||
delete from Customer where nr_orders == 10 && name == 'Bob'
|
delete from Customer where nr_orders == 10 && name == 'Bob'
|
||||||
}
|
}
|
||||||
|
sql db {
|
||||||
|
update Customer set name = 'Queen Elizabeth II', age = 150, nr_orders = 42, country = 'Great Britain'
|
||||||
|
where id == 5
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue