From db28796b5f7886dd34b852f2ab94d66647a164f8 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 23 Jun 2020 14:07:39 +0200 Subject: [PATCH] orm: handle bool literals for older sqlite versions --- vlib/v/gen/sql.v | 6 ++++++ vlib/v/parser/comptime.v | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/vlib/v/gen/sql.v b/vlib/v/gen/sql.v index 52fd707836..d7525d2865 100644 --- a/vlib/v/gen/sql.v +++ b/vlib/v/gen/sql.v @@ -206,6 +206,12 @@ fn (mut g Gen) expr_to_sql(expr ast.Expr) { g.inc_sql_i() 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 { // `name == user_name` => `name == ?1` // for left sides just add a string, for right sides, generate the bindings diff --git a/vlib/v/parser/comptime.v b/vlib/v/parser/comptime.v index e47caca449..09ed5bf503 100644 --- a/vlib/v/parser/comptime.v +++ b/vlib/v/parser/comptime.v @@ -100,9 +100,9 @@ fn (mut p Parser) vweb() ast.ComptimeCall { } // println('path is now "$path"') } - // if p.pref.is_verbose { - println('>>> compiling vweb HTML template "$path"') - // } + if p.pref.is_verbose { + println('>>> compiling vweb HTML template "$path"') + } v_code := tmpl.compile_file(path, p.cur_fn_name) mut scope := &ast.Scope{ start_pos: 0