From 6960914391c368d85c5ca5343b36315ec5f65400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wiktor=20=C5=BBurawik?= Date: Sat, 13 Feb 2021 19:08:47 +0100 Subject: [PATCH] Ensure that CHECK's expressions are wrapped in parentheses --- dev/statement_serializator.h | 6 ++++++ include/sqlite_orm/sqlite_orm.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/dev/statement_serializator.h b/dev/statement_serializator.h index e43801bac..a50d1c317 100644 --- a/dev/statement_serializator.h +++ b/dev/statement_serializator.h @@ -498,6 +498,9 @@ namespace sqlite_orm { std::string operator()(const statement_type &c, const C &context) const { std::stringstream ss; auto leftString = serialize(c.l, context); + if(context.use_parentheses) { + ss << '('; + } ss << leftString << " " << static_cast(c) << " ( "; for(size_t index = 0; index < c.arg.size(); ++index) { auto &value = c.arg[index]; @@ -507,6 +510,9 @@ namespace sqlite_orm { } } ss << " )"; + if(context.use_parentheses) { + ss << ')'; + } return ss.str(); } }; diff --git a/include/sqlite_orm/sqlite_orm.h b/include/sqlite_orm/sqlite_orm.h index 2567a34f8..22c493422 100644 --- a/include/sqlite_orm/sqlite_orm.h +++ b/include/sqlite_orm/sqlite_orm.h @@ -10048,6 +10048,9 @@ namespace sqlite_orm { std::string operator()(const statement_type &c, const C &context) const { std::stringstream ss; auto leftString = serialize(c.l, context); + if(context.use_parentheses) { + ss << '('; + } ss << leftString << " " << static_cast(c) << " ( "; for(size_t index = 0; index < c.arg.size(); ++index) { auto &value = c.arg[index]; @@ -10057,6 +10060,9 @@ namespace sqlite_orm { } } ss << " )"; + if(context.use_parentheses) { + ss << ')'; + } return ss.str(); } };