summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2015-10-16 19:44:43 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2015-10-16 19:44:43 +0100
commit2cb9eb569fa593aa00e5e746918778b82959dfbc (patch)
tree64d3661c72ca9be968b45d9afb5a1e9eba97cf5f
parentTest inserted converted values (diff)
downloadslicer-2cb9eb569fa593aa00e5e746918778b82959dfbc.tar.bz2
slicer-2cb9eb569fa593aa00e5e746918778b82959dfbc.tar.xz
slicer-2cb9eb569fa593aa00e5e746918778b82959dfbc.zip
Test select nulls/optionals
-rw-r--r--slicer/db/testSelect.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/slicer/db/testSelect.cpp b/slicer/db/testSelect.cpp
index 7e79780..a3b3cf8 100644
--- a/slicer/db/testSelect.cpp
+++ b/slicer/db/testSelect.cpp
@@ -197,3 +197,18 @@ BOOST_AUTO_TEST_CASE( select_inherit_emptySequence )
BOOST_REQUIRE_EQUAL(0, bi.size());
}
+BOOST_AUTO_TEST_CASE( select_null )
+{
+ auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ db->execute("INSERT INTO test(id) VALUES(NULL)");
+
+ auto sel = SelectPtr(db->newSelectCommand("SELECT id optSimple FROM test WHERE id IS NULL"));
+ auto oi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::OptionalsPtr>(*sel);
+ BOOST_REQUIRE(!oi->optSimple);
+
+ sel = SelectPtr(db->newSelectCommand("SELECT MAX(id) optSimple FROM test WHERE id IS NOT NULL"));
+ oi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::OptionalsPtr>(*sel);
+ BOOST_REQUIRE(oi->optSimple);
+ BOOST_REQUIRE_EQUAL(oi->optSimple.get(), 4);
+}
+