@@ -22,6 +22,7 @@ namespace sqlite_orm {
2222
2323 namespace internal {
2424 struct storage_base ;
25+ struct sqlite_executor ;
2526
2627 template <class T >
2728 int getPragmaCallback (void * data, int argc, char ** argv, char ** x) {
@@ -42,7 +43,8 @@ namespace sqlite_orm {
4243 struct pragma_t {
4344 using get_connection_t = std::function<internal::connection_ref()>;
4445
45- pragma_t (get_connection_t get_connection_) : get_connection(std::move(get_connection_)) {}
46+ pragma_t (get_connection_t get_connection_, const sqlite_executor& executor) :
47+ get_connection(std::move(get_connection_)), executor(executor) {}
4648
4749 std::vector<std::string> module_list () {
4850 return this ->get_pragma <std::vector<std::string>>(" module_list" );
@@ -156,13 +158,17 @@ namespace sqlite_orm {
156158 auto connection = this ->get_connection ();
157159
158160 std::vector<sqlite_orm::table_xinfo> result;
159- std::ostringstream ss;
160- ss << " PRAGMA "
161- " table_xinfo("
162- << streaming_identifier (tableName) << " )" << std::flush;
163- perform_exec (
161+ std::string sql;
162+ {
163+ std::ostringstream ss;
164+ ss << " PRAGMA "
165+ " table_xinfo("
166+ << streaming_identifier (tableName) << " )" << std::flush;
167+ sql = ss.str ();
168+ }
169+ this ->executor .perform_exec (
164170 connection.get (),
165- ss. str () ,
171+ sql ,
166172 [](void * data, int argc, char ** argv, char **) -> int {
167173 auto & res = *(std::vector<sqlite_orm::table_xinfo>*)data;
168174 if (argc) {
@@ -192,14 +198,18 @@ namespace sqlite_orm {
192198 std::vector<sqlite_orm::table_info> table_info (const std::string& tableName) const {
193199 auto connection = this ->get_connection ();
194200
195- std::ostringstream ss;
196- ss << " PRAGMA "
197- " table_info("
198- << streaming_identifier (tableName) << " )" << std::flush;
201+ std::string sql;
202+ {
203+ std::ostringstream ss;
204+ ss << " PRAGMA "
205+ " table_info("
206+ << streaming_identifier (tableName) << " )" << std::flush;
207+ sql = ss.str ();
208+ }
199209 std::vector<sqlite_orm::table_info> result;
200- perform_exec (
210+ this -> executor . perform_exec (
201211 connection.get (),
202- ss. str () ,
212+ sql ,
203213 [](void * data, int argc, char ** argv, char **) -> int {
204214 auto & res = *(std::vector<sqlite_orm::table_info>*)data;
205215 if (argc) {
@@ -225,12 +235,14 @@ namespace sqlite_orm {
225235 int synchronous_ = -1 ;
226236 signed char journal_mode_ = -1 ; // if != -1 stores static_cast<sqlite_orm::journal_mode>(journal_mode)
227237 get_connection_t get_connection;
238+ const sqlite_executor& executor;
228239
229240 template <class T >
230241 T get_pragma (const std::string& name) {
231242 auto connection = this ->get_connection ();
232243 T result;
233- perform_exec (connection.get (), " PRAGMA " + name, getPragmaCallback<T>, &result);
244+ const std::string sql = " PRAGMA " + name;
245+ this ->executor .perform_exec (connection.get (), sql, getPragmaCallback<T>, &result);
234246 return result;
235247 }
236248
@@ -257,12 +269,12 @@ namespace sqlite_orm {
257269 this ->set_pragma_impl (ss.str (), db);
258270 }
259271
260- void set_pragma_impl (const std::string& query , sqlite3* db = nullptr ) {
272+ void set_pragma_impl (const std::string& sql , sqlite3* db = nullptr ) {
261273 if (db) {
262- perform_void_exec (db, query );
274+ this -> executor . perform_void_exec (db, sql. data () );
263275 } else {
264- auto con = this ->get_connection ();
265- perform_void_exec (con .get (), query );
276+ auto connection = this ->get_connection ();
277+ this -> executor . perform_void_exec (connection .get (), sql. data () );
266278 }
267279 }
268280 };
0 commit comments