aboutsummaryrefslogtreecommitdiff
path: root/mysql
diff options
context:
space:
mode:
Diffstat (limited to 'mysql')
-rw-r--r--mysql/truncation/driver.cxx33
-rw-r--r--mysql/truncation/test.hxx34
2 files changed, 49 insertions, 18 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)
{
diff --git a/mysql/truncation/test.hxx b/mysql/truncation/test.hxx
index b3128c0..b1aae1a 100644
--- a/mysql/truncation/test.hxx
+++ b/mysql/truncation/test.hxx
@@ -6,19 +6,15 @@
#define TEST_HXX
#include <string>
+#include <vector>
+
#include <odb/core.hxx>
#pragma db object table ("test")
struct object1
{
- object1 (unsigned long id)
- : id_ (id)
- {
- }
-
- object1 ()
- {
- }
+ object1 () {}
+ object1 (unsigned long id): id_ (id) {}
#pragma db id
unsigned long id_;
@@ -29,14 +25,8 @@ struct object1
#pragma db object table ("test")
struct object2
{
- object2 (unsigned long id)
- : id_ (id)
- {
- }
-
- object2 ()
- {
- }
+ object2 () {}
+ object2 (unsigned long id): id_ (id) {}
#pragma db id
unsigned long id_;
@@ -44,4 +34,16 @@ struct object2
std::string str_;
};
+#pragma db object
+struct container
+{
+ container () {}
+ container (unsigned long id) : id_ (id) {}
+
+ #pragma db id
+ unsigned long id_;
+
+ std::vector<std::string> vec_;
+};
+
#endif // TEST_HXX