diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-04-30 12:05:12 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-04-30 12:08:00 +0200 |
commit | c48c8cd8b949cf6b9662596a6078cb6812087247 (patch) | |
tree | 958d72e450ab84361f222cb8947524f653223259 | |
parent | 673e3b37ad38402437956b692ed379a2ee7d083e (diff) |
Add transaction::connection(database&) overload
-rw-r--r-- | odb/mssql/database.cxx | 8 | ||||
-rw-r--r-- | odb/mssql/database.ixx | 2 | ||||
-rw-r--r-- | odb/mssql/polymorphic-object-statements.txx | 2 | ||||
-rw-r--r-- | odb/mssql/transaction-impl.hxx | 5 | ||||
-rw-r--r-- | odb/mssql/transaction-impl.ixx | 14 | ||||
-rw-r--r-- | odb/mssql/transaction.hxx | 3 | ||||
-rw-r--r-- | odb/mssql/transaction.ixx | 8 |
7 files changed, 17 insertions, 25 deletions
diff --git a/odb/mssql/database.cxx b/odb/mssql/database.cxx index 82c6a8c..6e68bcb 100644 --- a/odb/mssql/database.cxx +++ b/odb/mssql/database.cxx @@ -527,9 +527,11 @@ namespace odb if (!transaction::has_current ()) t.reset (factory_->connect ()->begin (), false); - mssql::connection& c (t.finalized () - ? transaction::current ().connection () - : t.connection ()); + mssql::connection& c ( + t.finalized () + ? transaction::current ().connection (const_cast<database&> (*this)) + : t.connection (const_cast<database&> (*this))); + try { select_statement st (c, diff --git a/odb/mssql/database.ixx b/odb/mssql/database.ixx index 30bdcdc..ae1b83b 100644 --- a/odb/mssql/database.ixx +++ b/odb/mssql/database.ixx @@ -628,7 +628,7 @@ namespace odb { // Throws if not in transaction. // - mssql::connection& c (transaction::current ().connection ()); + mssql::connection& c (transaction::current ().connection (*this)); return c.prepare_query<T> (n, q); } diff --git a/odb/mssql/polymorphic-object-statements.txx b/odb/mssql/polymorphic-object-statements.txx index c677d5d..0ba437a 100644 --- a/odb/mssql/polymorphic-object-statements.txx +++ b/odb/mssql/polymorphic-object-statements.txx @@ -107,7 +107,7 @@ namespace odb root_type& robj, const schema_version_migration* svm) { - connection_type& conn (transaction::current ().connection ()); + connection_type& conn (transaction::current ().connection (db)); polymorphic_derived_object_statements& sts ( conn.statement_cache ().find_object<object_type> ()); root_statements_type& rsts (sts.root_statements ()); diff --git a/odb/mssql/transaction-impl.hxx b/odb/mssql/transaction-impl.hxx index ec61336..f7189f2 100644 --- a/odb/mssql/transaction-impl.hxx +++ b/odb/mssql/transaction-impl.hxx @@ -38,17 +38,12 @@ namespace odb virtual void rollback (); - connection_type& - connection (); - private: connection_ptr connection_; }; } } -#include <odb/mssql/transaction-impl.ixx> - #include <odb/post.hxx> #endif // ODB_MSSQL_TRANSACTION_IMPL_HXX diff --git a/odb/mssql/transaction-impl.ixx b/odb/mssql/transaction-impl.ixx deleted file mode 100644 index 3b14a83..0000000 --- a/odb/mssql/transaction-impl.ixx +++ /dev/null @@ -1,14 +0,0 @@ -// file : odb/mssql/transaction-impl.ixx -// license : ODB NCUEL; see accompanying LICENSE file - -namespace odb -{ - namespace mssql - { - inline transaction_impl::connection_type& transaction_impl:: - connection () - { - return *connection_; - } - } -} diff --git a/odb/mssql/transaction.hxx b/odb/mssql/transaction.hxx index 0271f54..8c86515 100644 --- a/odb/mssql/transaction.hxx +++ b/odb/mssql/transaction.hxx @@ -41,6 +41,9 @@ namespace odb connection_type& connection (); + connection_type& + connection (odb::database&); + // Return current transaction or throw if there is no transaction // in effect. // diff --git a/odb/mssql/transaction.ixx b/odb/mssql/transaction.ixx index c9cbf34..ac819bc 100644 --- a/odb/mssql/transaction.ixx +++ b/odb/mssql/transaction.ixx @@ -39,7 +39,13 @@ namespace odb inline transaction::connection_type& transaction:: connection () { - return implementation ().connection (); + return static_cast<connection_type&> (odb::transaction::connection ()); + } + + inline transaction::connection_type& transaction:: + connection (odb::database& db) + { + return static_cast<connection_type&> (odb::transaction::connection (db)); } inline void transaction:: |