diff options
Diffstat (limited to 'slicer/db')
-rw-r--r-- | slicer/db/sqlInsertSerializer.cpp | 6 | ||||
-rw-r--r-- | slicer/db/sqlInsertSerializer.h | 4 | ||||
-rw-r--r-- | slicer/db/sqlSelectDeserializer.cpp | 2 | ||||
-rw-r--r-- | slicer/db/sqlSelectDeserializer.h | 4 | ||||
-rw-r--r-- | slicer/db/sqlTablePatchSerializer.cpp | 2 | ||||
-rw-r--r-- | slicer/db/sqlTablePatchSerializer.h | 4 | ||||
-rw-r--r-- | slicer/db/sqlUpdateSerializer.cpp | 2 | ||||
-rw-r--r-- | slicer/db/sqlUpdateSerializer.h | 4 | ||||
-rw-r--r-- | slicer/db/testInsert.cpp | 12 | ||||
-rw-r--r-- | slicer/db/testMockCommon.cpp | 3 | ||||
-rw-r--r-- | slicer/db/testMockCommon.h | 3 | ||||
-rw-r--r-- | slicer/db/testPatch.cpp | 2 | ||||
-rw-r--r-- | slicer/db/testSelect.cpp | 46 | ||||
-rw-r--r-- | slicer/db/testUpdate.cpp | 8 |
14 files changed, 52 insertions, 50 deletions
diff --git a/slicer/db/sqlInsertSerializer.cpp b/slicer/db/sqlInsertSerializer.cpp index 9d1da32..9647847 100644 --- a/slicer/db/sqlInsertSerializer.cpp +++ b/slicer/db/sqlInsertSerializer.cpp @@ -10,7 +10,7 @@ #include <boost/bind.hpp> namespace Slicer { - SqlInsertSerializer::SqlInsertSerializer(DB::ConnectionPtr const c, const std::string & t) : + SqlInsertSerializer::SqlInsertSerializer(DB::Connection * const c, const std::string & t) : connection(c), tableName(t) { @@ -57,7 +57,7 @@ namespace Slicer { class IdSave : public Slicer::ValueSource { public: - IdSave(const DB::ConnectionPtr & c) : + IdSave(DB::Connection * const c) : connection(c) { } @@ -79,7 +79,7 @@ namespace Slicer { NumType(Ice::Double); private: - const DB::ConnectionPtr & connection; + DB::Connection * const connection; }; void diff --git a/slicer/db/sqlInsertSerializer.h b/slicer/db/sqlInsertSerializer.h index 9c99f80..d5c8ced 100644 --- a/slicer/db/sqlInsertSerializer.h +++ b/slicer/db/sqlInsertSerializer.h @@ -9,7 +9,7 @@ namespace Slicer { class DLL_PUBLIC SqlInsertSerializer : public Slicer::Serializer { public: - SqlInsertSerializer(DB::ConnectionPtr const, const std::string & tableName); + SqlInsertSerializer(DB::Connection * const, const std::string & tableName); virtual void Serialize(Slicer::ModelPartForRootPtr) override; @@ -21,7 +21,7 @@ namespace Slicer { virtual void bindObjectAndExecute(Slicer::ModelPartPtr, DB::ModifyCommand *) const; virtual void bindObjectAndExecuteField(int & paramNo, DB::ModifyCommand *, Slicer::ModelPartPtr, const HookCommon *) const; - DB::ConnectionPtr const connection; + DB::Connection * const connection; const std::string tableName; }; diff --git a/slicer/db/sqlSelectDeserializer.cpp b/slicer/db/sqlSelectDeserializer.cpp index 5b226ce..0fa9892 100644 --- a/slicer/db/sqlSelectDeserializer.cpp +++ b/slicer/db/sqlSelectDeserializer.cpp @@ -4,7 +4,7 @@ #include <common.h> namespace Slicer { - SqlSelectDeserializer::SqlSelectDeserializer(DB::SelectCommandPtr c, IceUtil::Optional<std::string> tc) : + SqlSelectDeserializer::SqlSelectDeserializer(DB::SelectCommand * c, IceUtil::Optional<std::string> tc) : cmd(c), typeIdColName(tc) { diff --git a/slicer/db/sqlSelectDeserializer.h b/slicer/db/sqlSelectDeserializer.h index 72403ee..af39039 100644 --- a/slicer/db/sqlSelectDeserializer.h +++ b/slicer/db/sqlSelectDeserializer.h @@ -8,7 +8,7 @@ namespace Slicer { class DLL_PUBLIC SqlSelectDeserializer : public Slicer::Deserializer { public: - SqlSelectDeserializer(DB::SelectCommandPtr, IceUtil::Optional<std::string> typeIdCol = IceUtil::Optional<std::string>()); + SqlSelectDeserializer(DB::SelectCommand *, IceUtil::Optional<std::string> typeIdCol = IceUtil::Optional<std::string>()); virtual void Deserialize(Slicer::ModelPartForRootPtr) override; @@ -18,7 +18,7 @@ namespace Slicer { void DLL_PRIVATE DeserializeSequence(Slicer::ModelPartPtr); void DLL_PRIVATE DeserializeRow(Slicer::ModelPartPtr); - DB::SelectCommandPtr cmd; + DB::SelectCommand * cmd; unsigned int columnCount; IceUtil::Optional<std::string> typeIdColName; IceUtil::Optional<unsigned int> typeIdColIdx; diff --git a/slicer/db/sqlTablePatchSerializer.cpp b/slicer/db/sqlTablePatchSerializer.cpp index ed293ca..08aa14d 100644 --- a/slicer/db/sqlTablePatchSerializer.cpp +++ b/slicer/db/sqlTablePatchSerializer.cpp @@ -8,7 +8,7 @@ namespace Slicer { AdHocFormatter(ttname, "slicer_tmp_%?"); - SqlTablePatchSerializer::SqlTablePatchSerializer(DB::ConnectionPtr db, DB::TablePatch & tp) : + SqlTablePatchSerializer::SqlTablePatchSerializer(DB::Connection * const db, DB::TablePatch & tp) : db(db), tablePatch(tp) { diff --git a/slicer/db/sqlTablePatchSerializer.h b/slicer/db/sqlTablePatchSerializer.h index 41fb89d..c3b3b2d 100644 --- a/slicer/db/sqlTablePatchSerializer.h +++ b/slicer/db/sqlTablePatchSerializer.h @@ -7,7 +7,7 @@ namespace Slicer { class DLL_PUBLIC SqlTablePatchSerializer : public Slicer::Serializer { public: - SqlTablePatchSerializer(DB::ConnectionPtr, DB::TablePatch &); + SqlTablePatchSerializer(DB::Connection * const, DB::TablePatch &); ~SqlTablePatchSerializer(); virtual void Serialize(Slicer::ModelPartForRootPtr) override; @@ -16,7 +16,7 @@ namespace Slicer { void createTemporaryTable(); void dropTemporaryTable(); - DB::ConnectionPtr db; + DB::Connection * const db; DB::TablePatch & tablePatch; }; } diff --git a/slicer/db/sqlUpdateSerializer.cpp b/slicer/db/sqlUpdateSerializer.cpp index 6cd0360..c322ef1 100644 --- a/slicer/db/sqlUpdateSerializer.cpp +++ b/slicer/db/sqlUpdateSerializer.cpp @@ -9,7 +9,7 @@ #include <boost/bind.hpp> namespace Slicer { - SqlUpdateSerializer::SqlUpdateSerializer(DB::ConnectionPtr const c, const std::string & t) : + SqlUpdateSerializer::SqlUpdateSerializer(DB::Connection * const c, const std::string & t) : connection(c), tableName(t) { diff --git a/slicer/db/sqlUpdateSerializer.h b/slicer/db/sqlUpdateSerializer.h index fe6f4bc..f695634 100644 --- a/slicer/db/sqlUpdateSerializer.h +++ b/slicer/db/sqlUpdateSerializer.h @@ -8,7 +8,7 @@ namespace Slicer { class DLL_PUBLIC SqlUpdateSerializer : public Slicer::Serializer { public: - SqlUpdateSerializer(DB::ConnectionPtr const, const std::string & tableName); + SqlUpdateSerializer(DB::Connection * const, const std::string & tableName); virtual void Serialize(Slicer::ModelPartForRootPtr) override; @@ -18,7 +18,7 @@ namespace Slicer { DB::ModifyCommandPtr createUpdate(Slicer::ModelPartPtr) const; static void bindObjectAndExecute(Slicer::ModelPartPtr, DB::ModifyCommand *); - DB::ConnectionPtr const connection; + DB::Connection * const connection; const std::string tableName; }; } diff --git a/slicer/db/testInsert.cpp b/slicer/db/testInsert.cpp index 57716e3..7dbb6b7 100644 --- a/slicer/db/testInsert.cpp +++ b/slicer/db/testInsert.cpp @@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE( insert_builtins ) TestModule::BuiltInsPtr bi = std::make_shared<TestModule::BuiltIns>(true, 4, 16, 64, 128, 1.2, 3.4, "text"); Slicer::SerializeAny<Slicer::SqlInsertSerializer>(bi, db, "builtins"); auto sel = db->select("SELECT * FROM builtins"); - auto bi2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInsPtr>(sel); + auto bi2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInsPtr>(sel.get()); BOOST_REQUIRE_EQUAL(bi->mbool, bi2->mbool); BOOST_REQUIRE_EQUAL(bi->mbyte, bi2->mbyte); BOOST_REQUIRE_EQUAL(bi->mshort, bi2->mshort); @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE( insert_seq_builtins ) }; Slicer::SerializeAny<Slicer::SqlInsertSerializer>(bis, db, "builtins"); auto sel = db->select("SELECT * FROM builtins ORDER BY mint"); - auto bis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInSeq>(sel); + auto bis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInSeq>(sel.get()); BOOST_REQUIRE_EQUAL(3, bis2.size()); BOOST_REQUIRE_EQUAL(bis.back()->mbool, bis2.back()->mbool); BOOST_REQUIRE_EQUAL(bis.back()->mbyte, bis2.back()->mbyte); @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE( autoinsert_seq_builtins ) }; Slicer::SerializeAny<Slicer::SqlAutoIdInsertSerializer>(bis, db, "builtins"); auto sel = db->select("SELECT * FROM builtins WHERE mint IN (1, 2) ORDER BY mint"); - auto bis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInSeq>(sel); + auto bis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInSeq>(sel.get()); BOOST_REQUIRE_EQUAL(2, bis2.size()); BOOST_REQUIRE_EQUAL(bis.front()->mint, 0); BOOST_REQUIRE_EQUAL(bis.back()->mint, 0); @@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE( fetchinsert_seq_builtins ) }; Slicer::SerializeAny<Slicer::SqlFetchIdInsertSerializer>(bis, db, "builtins"); auto sel = db->select("SELECT * FROM builtins WHERE mint IN (3, 4) ORDER BY mint"); - auto bis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInSeq>(sel); + auto bis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInSeq>(sel.get()); BOOST_REQUIRE_EQUAL(2, bis2.size()); BOOST_REQUIRE_EQUAL(bis.front()->mint, 3); BOOST_REQUIRE_EQUAL(bis.back()->mint, 4); @@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE( fetchinsert_seq_builtinsWithNulls ) }; Slicer::SerializeAny<Slicer::SqlFetchIdInsertSerializer>(bis, db, "builtins"); auto sel = db->select("SELECT * FROM builtins WHERE mint IN (5, 6) ORDER BY mint"); - auto bis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::BuiltInSeq>(sel); + auto bis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::BuiltInSeq>(sel.get()); BOOST_REQUIRE_EQUAL(2, bis2.size()); BOOST_REQUIRE_EQUAL(bis.front()->mint, 5); BOOST_REQUIRE_EQUAL(bis.back()->mint, 6); @@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE( insert_converted ) ); Slicer::SerializeAny<Slicer::SqlInsertSerializer>(st, db, "converted"); auto sel = db->select("SELECT * FROM converted"); - auto st2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::SpecificTypesPtr>(sel); + auto st2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::SpecificTypesPtr>(sel.get()); BOOST_REQUIRE_EQUAL(st->date, st2->date); BOOST_REQUIRE_EQUAL(st->dt, st2->dt); BOOST_REQUIRE_EQUAL(st->ts->days, st2->ts->days); diff --git a/slicer/db/testMockCommon.cpp b/slicer/db/testMockCommon.cpp index 8053b3e..7102db7 100644 --- a/slicer/db/testMockCommon.cpp +++ b/slicer/db/testMockCommon.cpp @@ -8,7 +8,8 @@ DB::PluginMock<PQ::Mock>("user=postgres dbname=postgres", "pqmock", { } ConnectionFixture::ConnectionFixture() : - db(DB::MockDatabase::openConnectionTo("pqmock")) + _db(DB::MockDatabase::openConnectionTo("pqmock")), + db(_db.get()) { } diff --git a/slicer/db/testMockCommon.h b/slicer/db/testMockCommon.h index e55824f..bd9b11f 100644 --- a/slicer/db/testMockCommon.h +++ b/slicer/db/testMockCommon.h @@ -14,7 +14,8 @@ class DLL_PUBLIC ConnectionFixture { public: ConnectionFixture(); - DB::ConnectionPtr db; + DB::ConnectionPtr _db; + DB::Connection * const db; }; #endif diff --git a/slicer/db/testPatch.cpp b/slicer/db/testPatch.cpp index 294d218..bb32086 100644 --- a/slicer/db/testPatch.cpp +++ b/slicer/db/testPatch.cpp @@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE( insert_builtins ) tp.dest = "builtins"; Slicer::SerializeAny<Slicer::SqlTablePatchSerializer>(bis, db, tp); auto cmd = db->select("SELECT COUNT(*) FROM builtins"); - auto c = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, int>(cmd); + auto c = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, int>(cmd.get()); BOOST_REQUIRE_EQUAL(2, c); BOOST_REQUIRE_EQUAL(2, tp.pk.size()); DB::PrimaryKey pk = {"mint", "mlong"}; diff --git a/slicer/db/testSelect.cpp b/slicer/db/testSelect.cpp index da4b457..afcd3f2 100644 --- a/slicer/db/testSelect.cpp +++ b/slicer/db/testSelect.cpp @@ -18,35 +18,35 @@ BOOST_FIXTURE_TEST_SUITE(db, ConnectionFixture); BOOST_AUTO_TEST_CASE( select_simple_int ) { auto sel = db->select("SELECT MAX(id) FROM test"); - auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, Ice::Int>(sel); + auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, Ice::Int>(sel.get()); BOOST_REQUIRE_EQUAL(4, bi); } BOOST_AUTO_TEST_CASE( select_simple_double ) { auto sel = db->select("SELECT MAX(fl) FROM test"); - auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, Ice::Double>(sel); + auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, Ice::Double>(sel.get()); BOOST_REQUIRE_CLOSE(1234.1234, bi, 0.0001); } BOOST_AUTO_TEST_CASE( select_simple_string ) { auto sel = db->select("SELECT MAX(string) FROM test"); - auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, std::string>(sel); + auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, std::string>(sel.get()); BOOST_REQUIRE_EQUAL("text two", bi); } BOOST_AUTO_TEST_CASE( select_simple_true ) { auto sel = db->select("SELECT true"); - auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, bool>(sel); + auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, bool>(sel.get()); BOOST_REQUIRE_EQUAL(true, bi); } BOOST_AUTO_TEST_CASE( select_simple_false ) { auto sel = db->select("SELECT NOT(true)"); - auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, bool>(sel); + auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, bool>(sel.get()); BOOST_REQUIRE_EQUAL(false, bi); } @@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE( select_single ) FROM test \ ORDER BY id \ LIMIT 1"); - auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInsPtr>(sel); + auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInsPtr>(sel.get()); BOOST_REQUIRE(bi); BOOST_REQUIRE_EQUAL(true, bi->mbool); BOOST_REQUIRE_EQUAL(1, bi->mbyte); @@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE( select_inherit_single ) "SELECT id a, '::TestModule::D' || CAST(id AS TEXT) tc, 200 b, 300 c, 400 d \ FROM test \ WHERE id = 2"); - auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BasePtr>(sel, "tc"s); + auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BasePtr>(sel.get(), "tc"s); BOOST_REQUIRE(bi); auto d2 = std::dynamic_pointer_cast<TestModule::D2>(bi); BOOST_REQUIRE(d2); @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE( select_simple_sequence ) "SELECT string \ FROM test \ ORDER BY id DESC"); - auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::SimpleSeq>(sel); + auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::SimpleSeq>(sel.get()); BOOST_REQUIRE_EQUAL(4, bi.size()); BOOST_REQUIRE_EQUAL("text four", bi[0]); BOOST_REQUIRE_EQUAL("text three", bi[1]); @@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE( select_inherit_sequence ) FROM test \ WHERE id < 4 \ ORDER BY id DESC"); - auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BaseSeq>(sel, "tc"s); + auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BaseSeq>(sel.get(), "tc"s); BOOST_REQUIRE_EQUAL(3, bi.size()); auto d3 = std::dynamic_pointer_cast<TestModule::D3>(bi[0]); auto d2 = std::dynamic_pointer_cast<TestModule::D2>(bi[1]); @@ -130,7 +130,7 @@ BOOST_AUTO_TEST_CASE( select_inherit_datetime ) "SELECT dt, to_char(dt, 'YYYY-MM-DD') date, ts \ FROM test \ WHERE id = 3"); - TestDatabase::SpecificTypesPtr bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::SpecificTypesPtr>(sel); + TestDatabase::SpecificTypesPtr bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::SpecificTypesPtr>(sel.get()); BOOST_REQUIRE_EQUAL(2015, bi->dt.year); BOOST_REQUIRE_EQUAL(3, bi->dt.month); BOOST_REQUIRE_EQUAL(27, bi->dt.day); @@ -156,38 +156,38 @@ BoostThrowWrapperHelper(P && ... p) BOOST_AUTO_TEST_CASE( select_unsupportedModel ) { auto sel = db->select("SELECT id FROM test"); - BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<TestModule::ClassMap>(sel), Slicer::UnsupportedModelType); + BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<TestModule::ClassMap>(sel.get()), Slicer::UnsupportedModelType); } BOOST_AUTO_TEST_CASE( select_tooManyRowsSimple ) { auto sel = db->select("SELECT id FROM test"); - BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<Ice::Int>(sel), Slicer::TooManyRowsReturned); + BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<Ice::Int>(sel.get()), Slicer::TooManyRowsReturned); } BOOST_AUTO_TEST_CASE( select_noRowsSimple ) { auto sel = db->select("SELECT id FROM test WHERE false"); - BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<Ice::Int>(sel), Slicer::NoRowsReturned); + BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<Ice::Int>(sel.get()), Slicer::NoRowsReturned); } BOOST_AUTO_TEST_CASE( select_noRowsSimpleOptional ) { auto sel = db->select("SELECT id FROM test WHERE false"); - auto v = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, IceUtil::Optional<Ice::Int>>(sel); + auto v = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, IceUtil::Optional<Ice::Int>>(sel.get()); BOOST_REQUIRE(!v); } BOOST_AUTO_TEST_CASE( select_tooManyRowsSimpleOptional ) { auto sel = db->select("SELECT id FROM test"); - BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<IceUtil::Optional<Ice::Int>>(sel), Slicer::TooManyRowsReturned); + BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<IceUtil::Optional<Ice::Int>>(sel.get()), Slicer::TooManyRowsReturned); } BOOST_AUTO_TEST_CASE( select_simpleOptional ) { auto sel = db->select("SELECT MAX(id) FROM test"); - auto v = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, IceUtil::Optional<Ice::Int>>(sel); + auto v = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, IceUtil::Optional<Ice::Int>>(sel.get()); BOOST_REQUIRE(v); BOOST_REQUIRE_EQUAL(4, *v); } @@ -201,26 +201,26 @@ BOOST_AUTO_TEST_CASE( select_noRowsComplexOptional ) string mstring \ FROM test \ WHERE false"); - auto v = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, IceUtil::Optional<TestModule::BuiltInsPtr>>(sel); + auto v = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, IceUtil::Optional<TestModule::BuiltInsPtr>>(sel.get()); BOOST_REQUIRE(!v); } BOOST_AUTO_TEST_CASE( select_tooManyRowsComplex ) { auto sel = db->select("SELECT id FROM test"); - BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<TestModule::BuiltInsPtr>(sel), Slicer::TooManyRowsReturned); + BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<TestModule::BuiltInsPtr>(sel.get()), Slicer::TooManyRowsReturned); } BOOST_AUTO_TEST_CASE( select_noRowsComplex ) { auto sel = db->select("SELECT id FROM test WHERE false"); - BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<TestModule::BuiltInsPtr>(sel), Slicer::NoRowsReturned); + BOOST_REQUIRE_THROW(BoostThrowWrapperHelper<TestModule::BuiltInsPtr>(sel.get()), Slicer::NoRowsReturned); } BOOST_AUTO_TEST_CASE( select_emptySequence ) { auto sel = db->select("SELECT id FROM test WHERE false"); - auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BaseSeq>(sel); + auto bi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BaseSeq>(sel.get()); BOOST_REQUIRE_EQUAL(0, bi.size()); } @@ -229,16 +229,16 @@ BOOST_AUTO_TEST_CASE( select_null ) db->execute("INSERT INTO test(id) VALUES(NULL)"); auto sel = db->select("SELECT id optSimple FROM test WHERE id IS NULL"); - auto oi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::OptionalsPtr>(sel); + auto oi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::OptionalsPtr>(sel.get()); BOOST_REQUIRE(!oi->optSimple); sel = db->select("SELECT MAX(id) optSimple FROM test WHERE id IS NOT NULL"); - oi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::OptionalsPtr>(sel); + oi = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::OptionalsPtr>(sel.get()); BOOST_REQUIRE(oi->optSimple); BOOST_REQUIRE_EQUAL(*oi->optSimple, 4); sel = db->select("SELECT MAX(id) FROM test WHERE false"); - auto v = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, IceUtil::Optional<Ice::Int>>(sel); + auto v = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, IceUtil::Optional<Ice::Int>>(sel.get()); BOOST_REQUIRE(!v); } diff --git a/slicer/db/testUpdate.cpp b/slicer/db/testUpdate.cpp index 2f6d821..a76b9a1 100644 --- a/slicer/db/testUpdate.cpp +++ b/slicer/db/testUpdate.cpp @@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE( update_builtins ) Slicer::SerializeAny<Slicer::SqlUpdateSerializer>(ubi, db, "builtins"); auto sel = db->select("SELECT * FROM builtins ORDER BY mint DESC"); - auto bis = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInSeq>(sel); + auto bis = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInSeq>(sel.get()); BOOST_REQUIRE_EQUAL(2, bis.size()); BOOST_REQUIRE_EQUAL(bis.front()->mbool, ubi->mbool); BOOST_REQUIRE_EQUAL(bis.front()->mbyte, ubi->mbyte); @@ -63,7 +63,7 @@ BOOST_AUTO_TEST_CASE( update_builtins_seq ) Slicer::SerializeAny<Slicer::SqlUpdateSerializer>(ubis, db, "builtins"); auto sel = db->select("SELECT * FROM builtins ORDER BY mint"); - auto ubis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInSeq>(sel); + auto ubis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestModule::BuiltInSeq>(sel.get()); BOOST_REQUIRE_EQUAL(2, ubis2.size()); BOOST_REQUIRE_EQUAL(ubis.front()->mbool, ubis2.back()->mbool); BOOST_REQUIRE_EQUAL(ubis.front()->mbyte, ubis2.back()->mbyte); @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE( update_builtins_seq ) BOOST_AUTO_TEST_CASE( update_withNulls ) { auto sel = db->select("SELECT * FROM builtins ORDER BY mint"); - auto bis = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::BuiltInSeq>(sel); + auto bis = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::BuiltInSeq>(sel.get()); BOOST_REQUIRE_EQUAL(2, bis.size()); BOOST_REQUIRE_EQUAL("string updated", *bis[0]->mstring); BOOST_REQUIRE_EQUAL("string", *bis[1]->mstring); @@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE( update_withNulls ) bis[1]->mdouble = IceUtil::Optional<Ice::Double>(); BOOST_TEST_CHECKPOINT("Do update"); Slicer::SerializeAny<Slicer::SqlUpdateSerializer>(bis, db, "builtins"); - auto bis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::BuiltInSeq>(sel); + auto bis2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, TestDatabase::BuiltInSeq>(sel.get()); BOOST_REQUIRE(bis2[0]->mstring); BOOST_REQUIRE(!bis2[1]->mstring); BOOST_REQUIRE(bis2[0]->mbyte); |