aboutsummaryrefslogtreecommitdiff
path: root/mssql
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-12-22 11:50:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-01-20 15:45:46 +0200
commit2a8f6db525ba7f400c170cdd6321dcb20c2d24e3 (patch)
treedf9dcde0d665caf464cdbb41b3458ff16a945d11 /mssql
parent089a36ee4a3c7bf6d7288f021f135b8c4ffce8a0 (diff)
Test SQL Server long data in container
Diffstat (limited to 'mssql')
-rw-r--r--mssql/types/driver.cxx27
-rw-r--r--mssql/types/test.hxx39
2 files changed, 65 insertions, 1 deletions
diff --git a/mssql/types/driver.cxx b/mssql/types/driver.cxx
index 2266792..f4c9452 100644
--- a/mssql/types/driver.cxx
+++ b/mssql/types/driver.cxx
@@ -149,6 +149,33 @@ main (int argc, char* argv[])
assert (o2 == *p2);
}
}
+
+ // Test long data in containers.
+ //
+ {
+ long_cont o (1);
+ o.v.push_back (long_comp ("aaa", 123));
+ o.v.push_back (long_comp (string (500, 'b'), 234));
+ o.v.push_back (long_comp (string (70000, 'c'), 345));
+
+ // Persist.
+ //
+ {
+ transaction t (db->begin ());
+ db->persist (o);
+ t.commit ();
+ }
+
+ // Load.
+ //
+ {
+ transaction t (db->begin ());
+ auto_ptr<long_cont> p (db->load<long_cont> (1));
+ t.commit ();
+
+ assert (o == *p);
+ }
+ }
}
catch (const odb::exception& e)
{
diff --git a/mssql/types/test.hxx b/mssql/types/test.hxx
index 8cd689b..a0d261e 100644
--- a/mssql/types/test.hxx
+++ b/mssql/types/test.hxx
@@ -298,7 +298,6 @@ struct object
}
};
-
// Test long NULL data.
//
#pragma db object
@@ -322,4 +321,42 @@ struct long_null
}
};
+// Test long data in containers, in particular column re-arrangement.
+//
+#pragma db value
+struct long_comp
+{
+ long_comp () {}
+ long_comp (std::string s, unsigned int n): str (s), num (n) {}
+
+ #pragma db type ("VARCHAR(max)")
+ std::string str;
+
+ unsigned int num;
+
+ bool
+ operator== (const long_comp& y) const
+ {
+ return str == y.str && num == y.num;
+ }
+};
+
+#pragma db object
+struct long_cont
+{
+ long_cont () {}
+ long_cont (unsigned int id): id_ (id) {}
+
+ #pragma db id
+ unsigned int id_;
+
+ std::vector<long_comp> v;
+
+ bool
+ operator== (const long_cont& y) const
+ {
+ return id_ == y.id_ && v == y.v;
+ }
+};
+
#endif // TEST_HXX