From 89de275db2b77d0abf9fa1ec066ef11e262c88af Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 24 Jan 2013 15:10:22 +0200 Subject: Add support for mapping char[N] to CHAR/VARCHAR database types Also improve query support for arrays (decaying). --- sqlite/types/driver.cxx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'sqlite/types/driver.cxx') diff --git a/sqlite/types/driver.cxx b/sqlite/types/driver.cxx index 69e8473..4e619fb 100644 --- a/sqlite/types/driver.cxx +++ b/sqlite/types/driver.cxx @@ -69,6 +69,40 @@ main (int argc, char* argv[]) t.commit (); } #endif + + // Test char/wchar_t arrays + // + { +#ifndef _WIN32 + char_array o1 (1, ""); + char_array o2 (2, "1234567890"); + char_array o3 (3, "12345678901234567"); +#else + char_array o1 (1, "", L""); + char_array o2 (2, "1234567890", L"123456789\x00C8"); + char_array o3 (3, "12345678901234567", L"1234567890123456\x00C8"); +#endif + + { + transaction t (db->begin ()); + db->persist (o1); + db->persist (o2); + db->persist (o3); + t.commit (); + } + + { + transaction t (db->begin ()); + auto_ptr p1 (db->load (1)); + auto_ptr p2 (db->load (2)); + auto_ptr p3 (db->load (3)); + t.commit (); + + assert (o1 == *p1); + assert (o2 == *p2); + assert (o3 == *p3); + } + } } catch (const odb::exception& e) { -- cgit v1.1