diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-02-10 15:06:17 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-02-10 15:06:17 +0200 |
commit | c7d1b5f11a45319d71b6fe0929fc616a1640579f (patch) | |
tree | 30c82a9fa824ba3649da512826249fd7324b254b /mysql/truncation/driver.cxx | |
parent | d19c5d874860575e1aa379d6e55409a16d4455a5 (diff) |
Use correct truncation vector in container loading code
Diffstat (limited to 'mysql/truncation/driver.cxx')
-rw-r--r-- | mysql/truncation/driver.cxx | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/mysql/truncation/driver.cxx b/mysql/truncation/driver.cxx index 292d08f..43f18b3 100644 --- a/mysql/truncation/driver.cxx +++ b/mysql/truncation/driver.cxx @@ -10,6 +10,7 @@ #include <iostream> #include <odb/mysql/database.hxx> +#include <odb/mysql/connection.hxx> #include <odb/mysql/transaction.hxx> #include <common/common.hxx> @@ -23,9 +24,9 @@ using namespace odb::core; int main (int argc, char* argv[]) { - // The default pre-allocated buffer is 512 bytes long. + // The default pre-allocated buffer is 256 bytes long. // - string long_str (640, 'c'); // This will get the buffer to 1024 + string long_str (300, 'c'); // This will get the buffer to 512 string longer_str (1025, 'b'); try @@ -152,6 +153,34 @@ main (int argc, char* argv[]) t.commit (); } } + + // Test containers. + // + { + auto_ptr<database> db (create_database (argc, argv)); + + // Use different connections to persist and load the object. + // + connection_ptr c1 (db->connection ()); + connection_ptr c2 (db->connection ()); + + container o (1); + o.vec_.push_back (string (513, 'x')); + + { + transaction t (c1->begin ()); + db->persist (o); + t.commit (); + } + + { + transaction t (c2->begin ()); + auto_ptr<container> p (db->load<container> (1)); + t.commit (); + + assert (p->vec_ == o.vec_); + } + } } catch (const odb::exception& e) { |