orm: handle bool literals for older sqlite versions

pull/5462/head
Alexander Medvednikov 2020-06-23 14:07:39 +02:00
parent 16dd889922
commit db28796b5f
2 changed files with 9 additions and 3 deletions

View File

@ -206,6 +206,12 @@ fn (mut g Gen) expr_to_sql(expr ast.Expr) {
g.inc_sql_i() g.inc_sql_i()
g.sql_bind_int(it.val) g.sql_bind_int(it.val)
} }
ast.BoolLiteral {
// true/false literals were added to Sqlite 3.23 (2018-04-02)
// but lots of apps/distros use older sqlite (e.g. Ubuntu 18.04 LTS )
g.inc_sql_i()
g.sql_bind_int(if it.val { '1' } else { '0' })
}
ast.Ident { ast.Ident {
// `name == user_name` => `name == ?1` // `name == user_name` => `name == ?1`
// for left sides just add a string, for right sides, generate the bindings // for left sides just add a string, for right sides, generate the bindings

View File

@ -100,9 +100,9 @@ fn (mut p Parser) vweb() ast.ComptimeCall {
} }
// println('path is now "$path"') // println('path is now "$path"')
} }
// if p.pref.is_verbose { if p.pref.is_verbose {
println('>>> compiling vweb HTML template "$path"') println('>>> compiling vweb HTML template "$path"')
// } }
v_code := tmpl.compile_file(path, p.cur_fn_name) v_code := tmpl.compile_file(path, p.cur_fn_name)
mut scope := &ast.Scope{ mut scope := &ast.Scope{
start_pos: 0 start_pos: 0