From 2a8f6db525ba7f400c170cdd6321dcb20c2d24e3 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 22 Dec 2011 11:50:32 +0200 Subject: Test SQL Server long data in container --- mssql/types/driver.cxx | 27 +++++++++++++++++++++++++++ mssql/types/test.hxx | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) (limited to 'mssql') 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 p (db->load (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 v; + + bool + operator== (const long_cont& y) const + { + return id_ == y.id_ && v == y.v; + } +}; + #endif // TEST_HXX -- cgit v1.1