aboutsummaryrefslogtreecommitdiff
path: root/sqlite/types
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-09-10 12:12:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-09-10 12:12:06 +0200
commit32fcd732e2535090174142dd15b8b74fc444a9c2 (patch)
tree0d869cf45f1282cc1ac04e0d8171410d59d16a1f /sqlite/types
parent4e7f517a711d9b6e95512cad1891710bcd591034 (diff)
Add support for alternative UTF-16 image for TEXT in SQLite
Use it to handle QString and support std::wstring on Windows.
Diffstat (limited to 'sqlite/types')
-rw-r--r--sqlite/types/driver.cxx17
-rw-r--r--sqlite/types/test.hxx24
2 files changed, 30 insertions, 11 deletions
diff --git a/sqlite/types/driver.cxx b/sqlite/types/driver.cxx
index 1214d18..ac8c8d4 100644
--- a/sqlite/types/driver.cxx
+++ b/sqlite/types/driver.cxx
@@ -39,6 +39,9 @@ main (int argc, char* argv[])
string long_str (2040, 'l');
o.text_ = long_str;
+#ifdef _WIN32
+ o.wtext_ = L"t\x00C8st string";
+#endif
o.blob_.assign (long_str.c_str (), long_str.c_str () + long_str.size ());
{
@@ -47,8 +50,6 @@ main (int argc, char* argv[])
t.commit ();
}
- //
- //
{
transaction t (db->begin ());
auto_ptr<object> o1 (db->load<object> (1));
@@ -56,6 +57,18 @@ main (int argc, char* argv[])
assert (o == *o1);
}
+
+ typedef odb::query<object> query;
+ typedef odb::result<object> result;
+
+#ifdef _WIN32
+ {
+ transaction t (db->begin ());
+ result r (db->query<object> (query::wtext == L"t\x00C8st string"));
+ assert (!r.empty ());
+ t.commit ();
+ }
+#endif
}
catch (const odb::exception& e)
{
diff --git a/sqlite/types/test.hxx b/sqlite/types/test.hxx
index 897590d..bd8f48a 100644
--- a/sqlite/types/test.hxx
+++ b/sqlite/types/test.hxx
@@ -44,6 +44,10 @@ struct object
#pragma db type("TEXT")
std::string text_;
+#ifdef _WIN32
+ std::string wtext_;
+#endif
+
#pragma db type("BLOB")
std::vector<char> blob_;
@@ -55,15 +59,17 @@ struct object
bool
operator== (const object& y) const
{
- return
- id_ == y.id_ &&
- bool_ == y.bool_ &&
- integer_ == y.integer_ &&
- real_ == y.real_ &&
- nan_ != nan_ &&
- text_ == y.text_ &&
- blob_ == y.blob_ &&
- ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_);
+ return id_ == y.id_
+ && bool_ == y.bool_
+ && integer_ == y.integer_
+ && real_ == y.real_
+ && nan_ != nan_
+ && text_ == y.text_
+#ifdef _WIN32
+ && wtext_ == y.wtext_
+#endif
+ && blob_ == y.blob_
+ && ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_);
}
};