diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-11-15 12:04:57 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-11-16 11:25:05 +0200 |
commit | 7b6ace8f265e12704cc1d7e0c6f26dfe51ea2809 (patch) | |
tree | 9a225b06e2938f487fb9ec90ca4dcd40698260ab | |
parent | 1792e4f1aba7a60ae4ae6a227982da5459d34cfc (diff) |
Add tests for Oracle LOB support of QByteArray and QString
-rw-r--r-- | qt/oracle/basic/driver.cxx | 13 | ||||
-rw-r--r-- | qt/oracle/basic/test.hxx | 18 |
2 files changed, 25 insertions, 6 deletions
diff --git a/qt/oracle/basic/driver.cxx b/qt/oracle/basic/driver.cxx index 926ea8f..39f6b41 100644 --- a/qt/oracle/basic/driver.cxx +++ b/qt/oracle/basic/driver.cxx @@ -9,6 +9,7 @@ #include <memory> // std::auto_ptr #include <cassert> #include <iostream> +#include <string> #include <odb/oracle/database.hxx> #include <odb/oracle/transaction.hxx> @@ -28,9 +29,15 @@ main (int argc, char* argv[]) { auto_ptr<database> db (create_database (argc, argv)); + string long_str (20000, 'l'); + object o; - o.str = "John Doe"; - o.blob = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); + o.varchar = "John Doe"; + o.clob = QString::fromStdString (string (150, 'c')); + o.nclob = QString::fromStdString (long_str); + o.raw = QByteArray ("\0x13\0xDE\0x00\0x00\0x00\0x54\0xF2\0x6A", 8); + o.blob = QByteArray (long_str.c_str (), + static_cast<int> (long_str.size ())); // Persist. // @@ -44,7 +51,7 @@ main (int argc, char* argv[]) // { transaction t (db->begin ()); - object* ol = db->load<object> (o.str); + object* ol = db->load<object> (o.varchar); t.commit (); assert (*ol == o); diff --git a/qt/oracle/basic/test.hxx b/qt/oracle/basic/test.hxx index 25710c0..979e11f 100644 --- a/qt/oracle/basic/test.hxx +++ b/qt/oracle/basic/test.hxx @@ -16,14 +16,26 @@ struct object operator== (const object& x) const { return - str == x.str && - blob == x.blob; + varchar == x.varchar && + clob == x.clob && + nclob == x.nclob && + blob == x.blob && + raw == x.raw; } #pragma db id - QString str; + QString varchar; + + #pragma db type ("CLOB") + QString clob; + + #pragma db type ("NCLOB") + QString nclob; QByteArray blob; + + #pragma db type ("RAW(128)") + QByteArray raw; }; #endif // TEST_HXX |