From 2cb9eb569fa593aa00e5e746918778b82959dfbc Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 16 Oct 2015 19:44:43 +0100 Subject: Test select nulls/optionals --- slicer/db/testSelect.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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(*sel); + BOOST_REQUIRE(!oi->optSimple); + + sel = SelectPtr(db->newSelectCommand("SELECT MAX(id) optSimple FROM test WHERE id IS NOT NULL")); + oi = Slicer::DeserializeAny(*sel); + BOOST_REQUIRE(oi->optSimple); + BOOST_REQUIRE_EQUAL(oi->optSimple.get(), 4); +} + -- cgit v1.2.3