aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/database.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/sqlite/database.cxx')
-rw-r--r--odb/sqlite/database.cxx36
1 files changed, 32 insertions, 4 deletions
diff --git a/odb/sqlite/database.cxx b/odb/sqlite/database.cxx
index 79c8666..a7cf098 100644
--- a/odb/sqlite/database.cxx
+++ b/odb/sqlite/database.cxx
@@ -1,5 +1,4 @@
// file : odb/sqlite/database.cxx
-// copyright : Copyright (c) 2009-2019 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file
#ifdef _WIN32
@@ -152,8 +151,35 @@ namespace odb
factory_->database (*this);
}
+ database::
+ database (const connection_ptr& conn,
+ const string& name,
+ const string& schema,
+ transfer_ptr<attached_connection_factory> factory)
+ : odb::database (id_sqlite),
+ name_ (name),
+ schema_ (schema),
+ flags_ (0),
+ factory_ (factory.transfer ())
+ {
+ assert (!schema_.empty ());
+
+ // Copy some things over from the connection's database.
+ //
+ database& db (conn->database ());
+
+ tracer_ = db.tracer_;
+ foreign_keys_ = db.foreign_keys_;
+
+ if (!factory_)
+ factory_.reset (new default_attached_connection_factory (
+ connection::main_connection (conn)));
+
+ factory_->database (*this);
+ }
+
void database::
- print_usage (std::ostream& os)
+ print_usage (ostream& os)
{
details::options::print_usage (os);
}
@@ -197,7 +223,7 @@ namespace odb
else if (!schema_version_table_.empty ())
text += schema_version_table_; // Already quoted.
else
- text += "\"schema_version\"";
+ text += "\"main\".\"schema_version\"";
text += " WHERE \"name\" = ?";
@@ -226,7 +252,9 @@ namespace odb
cp = factory_->connect ();
sqlite::connection& c (
- cp != 0 ? *cp : transaction::current ().connection ());
+ cp != 0
+ ? *cp
+ : transaction::current ().connection (const_cast<database&> (*this)));
try
{