fmt: smarter wrap of orm lines (#7070)

pull/7080/head
Lukas Neubert 2020-12-02 04:06:20 +01:00 committed by GitHub
parent 7c394b9d58
commit dedb8f7e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -465,6 +465,7 @@ pub fn (mut f Fmt) stmt(node ast.Stmt) {
} else {
f.write(' ')
}
f.wrap_long_line(2, true)
}
f.write('where ')
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 {
if f.line_len <= max_len[penalty] {
pub fn (mut f Fmt) wrap_long_line(penalty_idx int, add_indent bool) bool {
if f.line_len <= max_len[penalty_idx] {
return false
}
if f.out.buf[f.out.buf.len - 1] == ` ` {

View File

@ -46,4 +46,8 @@ fn main() {
sql db {
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
}
}