diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-16 19:36:36 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-16 19:36:36 +0100 |
commit | 585b7da8f3842d75f9d2a5b423558416ab6b8d38 (patch) | |
tree | 1b0ead10302f156fde69fd1d5800a0419abcf602 | |
parent | Add basic support for insert serialization of objects and sequences of objects (diff) | |
download | slicer-585b7da8f3842d75f9d2a5b423558416ab6b8d38.tar.bz2 slicer-585b7da8f3842d75f9d2a5b423558416ab6b8d38.tar.xz slicer-585b7da8f3842d75f9d2a5b423558416ab6b8d38.zip |
Test inserted converted values
-rw-r--r-- | slicer/db/slicer.sql | 4 | ||||
-rw-r--r-- | slicer/db/testInsert.cpp | 20 |
2 files changed, 24 insertions, 0 deletions
diff --git a/slicer/db/slicer.sql b/slicer/db/slicer.sql index d77c15c..e526db3 100644 --- a/slicer/db/slicer.sql +++ b/slicer/db/slicer.sql @@ -21,3 +21,7 @@ CREATE TABLE builtins( mdouble numeric(8, 5), mstring text); +CREATE TABLE Converted( + dt timestamp without time zone, + date varchar(10), + ts interval); diff --git a/slicer/db/testInsert.cpp b/slicer/db/testInsert.cpp index 9d7bf04..fcea462 100644 --- a/slicer/db/testInsert.cpp +++ b/slicer/db/testInsert.cpp @@ -8,6 +8,10 @@ #include "sqlSelectDeserializer.h" #include <types.h> +BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::DateTime); +BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::IsoDate); +BOOST_TEST_DONT_PRINT_LOG_VALUE(DB::Timespan); + class StandardMockDatabase : public PQ::Mock { public: StandardMockDatabase() : PQ::Mock("user=postgres dbname=postgres", "pqmock", { @@ -59,3 +63,19 @@ BOOST_AUTO_TEST_CASE( insert_seq_builtins ) BOOST_REQUIRE_EQUAL(bis.back()->mstring, bis2.back()->mstring); } +BOOST_AUTO_TEST_CASE( insert_converted ) +{ + auto db = DBPtr(DB::MockDatabase::openConnectionTo("pqmock")); + DB::SpecificTypesPtr st = new DB::SpecificTypes { + {2015, 10, 16, 19, 12, 34}, + {2015, 10, 16}, + {1, 2, 3, 4} + }; + Slicer::SerializeAny<Slicer::SqlInsertSerializer>(st, db.get(), "converted"); + auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM converted")); + auto st2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, DB::SpecificTypesPtr>(*sel); + BOOST_REQUIRE_EQUAL(st->date, st2->date); + BOOST_REQUIRE_EQUAL(st->dt, st2->dt); + BOOST_REQUIRE_EQUAL(st->ts, st2->ts); +} + |