diff --git a/Data/ODBC/include/Poco/Data/ODBC/SessionImpl.h b/Data/ODBC/include/Poco/Data/ODBC/SessionImpl.h index 76b93062f..e9415bf37 100644 --- a/Data/ODBC/include/Poco/Data/ODBC/SessionImpl.h +++ b/Data/ODBC/include/Poco/Data/ODBC/SessionImpl.h @@ -222,6 +222,42 @@ inline Poco::Any SessionImpl::dataTypeInfo(const std::string& rName) } +inline void SessionImpl::setEnforceCapability(const std::string&, bool val) +{ + _enforceCapability = val; +} + + +inline bool SessionImpl::getEnforceCapability(const std::string&) +{ + return _enforceCapability; +} + + +inline void SessionImpl::autoBind(const std::string&, bool val) +{ + _autoBind = val; +} + + +inline bool SessionImpl::isAutoBind(const std::string& name) +{ + return _autoBind; +} + + +inline void SessionImpl::autoExtract(const std::string&, bool val) +{ + _autoExtract = val; +} + + +inline bool SessionImpl::isAutoExtract(const std::string& name) +{ + return _autoExtract; +} + + } } } // namespace Poco::Data::ODBC diff --git a/Data/ODBC/src/ODBCColumn.cpp b/Data/ODBC/src/ODBCColumn.cpp index b480ec31e..de0749bcb 100644 --- a/Data/ODBC/src/ODBCColumn.cpp +++ b/Data/ODBC/src/ODBCColumn.cpp @@ -104,6 +104,7 @@ void ODBCColumn::init() case SQL_CHAR: case SQL_VARCHAR: case SQL_LONGVARCHAR: + case -9:// SQL Server NVARCHAR setType(MetaColumn::FDT_STRING); break; case SQL_TINYINT: setType(MetaColumn::FDT_INT8); break; diff --git a/Data/ODBC/src/SessionImpl.cpp b/Data/ODBC/src/SessionImpl.cpp index d509dc9aa..375611daa 100644 --- a/Data/ODBC/src/SessionImpl.cpp +++ b/Data/ODBC/src/SessionImpl.cpp @@ -203,8 +203,12 @@ void SessionImpl::close() { if (!isConnected()) return; - commit(); - checkError(SQLDisconnect(_db)); + try + { + commit(); + }catch (ConnectionException&) { } + + SQLDisconnect(_db); } @@ -265,40 +269,4 @@ int SessionImpl::maxStatementLength() } -void SessionImpl::setEnforceCapability(const std::string&, bool val) -{ - _enforceCapability = val; -} - - -bool SessionImpl::getEnforceCapability(const std::string&) -{ - return _enforceCapability; -} - - -void SessionImpl::autoBind(const std::string&, bool val) -{ - _autoBind = val; -} - - -bool SessionImpl::isAutoBind(const std::string& name) -{ - return _autoBind; -} - - -void SessionImpl::autoExtract(const std::string&, bool val) -{ - _autoExtract = val; -} - - -bool SessionImpl::isAutoExtract(const std::string& name) -{ - return _autoExtract; -} - - } } } // namespace Poco::Data::ODBC diff --git a/Data/ODBC/testsuite/src/ODBCAccessTest.cpp b/Data/ODBC/testsuite/src/ODBCAccessTest.cpp index e2da4e128..254bc67f5 100644 --- a/Data/ODBC/testsuite/src/ODBCAccessTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCAccessTest.cpp @@ -49,28 +49,28 @@ using namespace Poco::Data; -using Poco::Data::ODBC::Utility; -using Poco::Data::ODBC::ConnectionException; -using Poco::Data::ODBC::StatementException; -using Poco::Data::ODBC::StatementDiagnostics; +using ODBC::Utility; +using ODBC::ConnectionException; +using ODBC::StatementException; +using ODBC::StatementDiagnostics; using Poco::format; using Poco::NotFoundException; -Poco::SharedPtr ODBCAccessTest::_pSession = 0; -std::string ODBCAccessTest::_dbConnString; -Poco::Data::ODBC::Utility::DriverMap ODBCAccessTest::_drivers; +Session* ODBCAccessTest::_pSession = 0; +std::string ODBCAccessTest::_dbConnString; +ODBC::Utility::DriverMap ODBCAccessTest::_drivers; ODBCAccessTest::ODBCAccessTest(const std::string& name): CppUnit::TestCase(name) { + ODBC::Connector::registerConnector(); } ODBCAccessTest::~ODBCAccessTest() { - ODBC::Connector::unregisterConnector(); } diff --git a/Data/ODBC/testsuite/src/ODBCAccessTest.h b/Data/ODBC/testsuite/src/ODBCAccessTest.h index 0c51aa7a0..274c9d6aa 100644 --- a/Data/ODBC/testsuite/src/ODBCAccessTest.h +++ b/Data/ODBC/testsuite/src/ODBCAccessTest.h @@ -72,7 +72,7 @@ private: static Poco::Data::ODBC::Utility::DriverMap _drivers; static std::string _dbConnString; - static Poco::SharedPtr _pSession; + static Poco::Data::Session* _pSession; bool _owner; }; diff --git a/Data/ODBC/testsuite/src/ODBCDB2Test.cpp b/Data/ODBC/testsuite/src/ODBCDB2Test.cpp index 6e6ad07a5..4f86539e8 100644 --- a/Data/ODBC/testsuite/src/ODBCDB2Test.cpp +++ b/Data/ODBC/testsuite/src/ODBCDB2Test.cpp @@ -50,20 +50,21 @@ using namespace Poco::Data; -using Poco::Data::ODBC::Utility; -using Poco::Data::ODBC::ConnectionException; -using Poco::Data::ODBC::StatementException; -using Poco::Data::ODBC::StatementDiagnostics; +using ODBC::Utility; +using ODBC::ConnectionException; +using ODBC::StatementException; +using ODBC::StatementDiagnostics; using Poco::format; using Poco::Tuple; using Poco::NotFoundException; -const bool ODBCDB2Test::bindValues[8] = {true, true, true, false, false, true, false, false}; -Poco::SharedPtr ODBCDB2Test::_pSession = 0; -Poco::SharedPtr ODBCDB2Test::_pExecutor = 0; -std::string ODBCDB2Test::_dbConnString; -Poco::Data::ODBC::Utility::DriverMap ODBCDB2Test::_drivers; +ODBCDB2Test::SessionPtr ODBCDB2Test::_pSession = 0; +ODBCDB2Test::ExecPtr ODBCDB2Test::_pExecutor = 0; +std::string ODBCDB2Test::_dbConnString; +ODBCDB2Test::Drivers ODBCDB2Test::_drivers; +const bool ODBCDB2Test::bindValues[8] = + {true, true, true, false, false, true, false, false}; ODBCDB2Test::ODBCDB2Test(const std::string& name): diff --git a/Data/ODBC/testsuite/src/ODBCDB2Test.h b/Data/ODBC/testsuite/src/ODBCDB2Test.h index 9579152aa..1e6f2117b 100644 --- a/Data/ODBC/testsuite/src/ODBCDB2Test.h +++ b/Data/ODBC/testsuite/src/ODBCDB2Test.h @@ -131,6 +131,10 @@ public: static CppUnit::Test* suite(); private: + typedef Poco::Data::ODBC::Utility::DriverMap Drivers; + typedef Poco::SharedPtr SessionPtr; + typedef Poco::SharedPtr ExecPtr; + void dropObject(const std::string& type, const std::string& tableName); void recreatePersonTable(); void recreatePersonBLOBTable(); @@ -145,11 +149,11 @@ private: static bool init(const std::string& driver, const std::string& dsn); static bool canConnect(const std::string& driver, const std::string& dsn); - static Poco::Data::ODBC::Utility::DriverMap _drivers; + static Drivers _drivers; static std::string _dbConnString; - static Poco::SharedPtr _pSession; - static Poco::SharedPtr _pExecutor; - static const bool bindValues[8]; + static SessionPtr _pSession; + static ExecPtr _pExecutor; + static const bool bindValues[8]; }; diff --git a/Data/ODBC/testsuite/src/ODBCMySQLTest.cpp b/Data/ODBC/testsuite/src/ODBCMySQLTest.cpp index b499e6719..a7283fd32 100644 --- a/Data/ODBC/testsuite/src/ODBCMySQLTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCMySQLTest.cpp @@ -50,20 +50,21 @@ using namespace Poco::Data; -using Poco::Data::ODBC::Utility; -using Poco::Data::ODBC::ConnectionException; -using Poco::Data::ODBC::StatementException; -using Poco::Data::ODBC::StatementDiagnostics; +using ODBC::Utility; +using ODBC::ConnectionException; +using ODBC::StatementException; +using ODBC::StatementDiagnostics; using Poco::format; using Poco::Tuple; using Poco::NotFoundException; -const bool ODBCMySQLTest::bindValues[8] = {true, true, true, false, false, true, false, false}; -Poco::SharedPtr ODBCMySQLTest::_pSession = 0; -Poco::SharedPtr ODBCMySQLTest::_pExecutor = 0; -std::string ODBCMySQLTest::_dbConnString; -Poco::Data::ODBC::Utility::DriverMap ODBCMySQLTest::_drivers; +ODBCMySQLTest::SessionPtr ODBCMySQLTest::_pSession = 0; +ODBCMySQLTest::ExecPtr ODBCMySQLTest::_pExecutor = 0; +std::string ODBCMySQLTest::_dbConnString; +ODBCMySQLTest::Drivers ODBCMySQLTest::_drivers; +const bool ODBCMySQLTest::bindValues[8] = + {true, true, true, false, false, true, false, false}; ODBCMySQLTest::ODBCMySQLTest(const std::string& name): diff --git a/Data/ODBC/testsuite/src/ODBCMySQLTest.h b/Data/ODBC/testsuite/src/ODBCMySQLTest.h index 1dacdb9a0..b96209a25 100644 --- a/Data/ODBC/testsuite/src/ODBCMySQLTest.h +++ b/Data/ODBC/testsuite/src/ODBCMySQLTest.h @@ -133,6 +133,10 @@ public: static CppUnit::Test* suite(); private: + typedef Poco::Data::ODBC::Utility::DriverMap Drivers; + typedef Poco::SharedPtr SessionPtr; + typedef Poco::SharedPtr ExecPtr; + void dropObject(const std::string& type, const std::string& name); void recreatePersonTable(); void recreatePersonBLOBTable(); @@ -147,11 +151,11 @@ private: static bool init(const std::string& driver, const std::string& dsn); static bool canConnect(const std::string& driver, const std::string& dsn); - static Poco::Data::ODBC::Utility::DriverMap _drivers; + static Drivers _drivers; static std::string _dbConnString; - static Poco::SharedPtr _pSession; - static Poco::SharedPtr _pExecutor; - static const bool bindValues[8]; + static SessionPtr _pSession; + static ExecPtr _pExecutor; + static const bool bindValues[8]; }; diff --git a/Data/ODBC/testsuite/src/ODBCOracleTest.cpp b/Data/ODBC/testsuite/src/ODBCOracleTest.cpp index bd3d98267..9627be67a 100644 --- a/Data/ODBC/testsuite/src/ODBCOracleTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCOracleTest.cpp @@ -51,21 +51,22 @@ using namespace Poco::Data; -using Poco::Data::ODBC::Utility; -using Poco::Data::ODBC::ConnectionException; -using Poco::Data::ODBC::StatementException; -using Poco::Data::ODBC::StatementDiagnostics; +using ODBC::Utility; +using ODBC::ConnectionException; +using ODBC::StatementException; +using ODBC::StatementDiagnostics; using Poco::format; using Poco::Tuple; using Poco::DateTime; using Poco::NotFoundException; -const bool ODBCOracleTest::bindValues[8] = {true, true, true, false, false, true, false, false}; -Poco::SharedPtr ODBCOracleTest::_pSession = 0; -Poco::SharedPtr ODBCOracleTest::_pExecutor = 0; -std::string ODBCOracleTest::_dbConnString; -Poco::Data::ODBC::Utility::DriverMap ODBCOracleTest::_drivers; +ODBCOracleTest::SessionPtr ODBCOracleTest::_pSession = 0; +ODBCOracleTest::ExecPtr ODBCOracleTest::_pExecutor = 0; +std::string ODBCOracleTest::_dbConnString; +ODBC::Utility::DriverMap ODBCOracleTest::_drivers; +const bool ODBCOracleTest::bindValues[8] = + {true, true, true, false, false, true, false, false}; ODBCOracleTest::ODBCOracleTest(const std::string& name): @@ -79,10 +80,8 @@ ODBCOracleTest::~ODBCOracleTest() } -void ODBCOracleTest::testBareboneODBC() +void ODBCOracleTest::testBarebone() { - if (!_pSession) fail ("Test not available."); - std::string tableCreateString = "CREATE TABLE Test " "(First VARCHAR(30)," "Second VARCHAR(30)," @@ -1297,6 +1296,15 @@ bool ODBCOracleTest::init(const std::string& driver, const std::string& dsn) _pExecutor = new SQLExecutor(driver + " SQL Executor", _pSession); + // Workaround: + // + // Barebone ODBC test is called initially for Oracle only. + // The test framework does not exit cleanly if + // Oracle tests are enabled (i.e. Oracle driver is found) + // but no tests are executed. + // The exact reason for this behavior is unknown at this time. + testBarebone(); + return true; } diff --git a/Data/ODBC/testsuite/src/ODBCOracleTest.h b/Data/ODBC/testsuite/src/ODBCOracleTest.h index 69a8ac50e..9090c2e7a 100644 --- a/Data/ODBC/testsuite/src/ODBCOracleTest.h +++ b/Data/ODBC/testsuite/src/ODBCOracleTest.h @@ -131,6 +131,12 @@ public: static CppUnit::Test* suite(); private: + typedef Poco::Data::ODBC::Utility::DriverMap Drivers; + typedef Poco::SharedPtr SessionPtr; + typedef Poco::SharedPtr ExecPtr; + + static void testBarebone(); + void dropObject(const std::string& type, const std::string& name); void recreatePersonTable(); void recreatePersonBLOBTable(); @@ -145,12 +151,18 @@ private: static bool init(const std::string& driver, const std::string& dsn); static bool canConnect(const std::string& driver, const std::string& dsn); - static Poco::Data::ODBC::Utility::DriverMap _drivers; + static Drivers _drivers; static std::string _dbConnString; - static Poco::SharedPtr _pSession; - static Poco::SharedPtr _pExecutor; - static const bool bindValues[8]; + static SessionPtr _pSession; + static ExecPtr _pExecutor; + static const bool bindValues[8]; }; +inline void ODBCOracleTest::testBareboneODBC() +{ + return testBarebone(); +} + + #endif // ODBCOracleTest_INCLUDED diff --git a/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp b/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp index 03d74cf2c..b812e38b2 100644 --- a/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp @@ -51,22 +51,25 @@ using namespace Poco::Data; -using Poco::Data::ODBC::Utility; -using Poco::Data::ODBC::ODBCException; -using Poco::Data::ODBC::ConnectionException; -using Poco::Data::ODBC::StatementException; -using Poco::Data::ODBC::StatementDiagnostics; +using ODBC::Utility; +using ODBC::ODBCException; +using ODBC::ConnectionException; +using ODBC::StatementException; +using ODBC::StatementDiagnostics; using Poco::format; using Poco::Tuple; using Poco::DateTime; using Poco::NotFoundException; -const bool ODBCPostgreSQLTest::bindValues[8] = {true, true, true, false, false, true, false, false}; -Poco::SharedPtr ODBCPostgreSQLTest::_pSession = 0; -Poco::SharedPtr ODBCPostgreSQLTest::_pExecutor = 0; -std::string ODBCPostgreSQLTest::_dbConnString; -Poco::Data::ODBC::Utility::DriverMap ODBCPostgreSQLTest::_drivers; +ODBCPostgreSQLTest::SessionPtr ODBCPostgreSQLTest::_pSession = 0; +ODBCPostgreSQLTest::ExecPtr ODBCPostgreSQLTest::_pExecutor = 0; +std::string ODBCPostgreSQLTest::_dbConnString; +ODBCPostgreSQLTest::Drivers ODBCPostgreSQLTest::_drivers; +const bool ODBCPostgreSQLTest::bindValues[8] = + {true, true, true, false, false, true, false, false}; + + #ifdef POCO_OS_FAMILY_WINDOWS const std::string ODBCPostgreSQLTest::libDir = "C:\\\\Program Files\\\\PostgreSQL\\\\8.2\\\\lib\\\\"; #else @@ -1222,7 +1225,7 @@ bool ODBCPostgreSQLTest::init(const std::string& driver, const std::string& dsn) CppUnit::Test* ODBCPostgreSQLTest::suite() { if (init("PostgreSQL ANSI", "PocoDataPostgreSQLTest")) - //if (init("Mammoth ODBCng Beta", "Mammoth ODBCng beta")) + //if (init("Mammoth ODBCng Beta", "Mammoth ODBCng Beta")) { CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ODBCPostgreSQLTest"); diff --git a/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.h b/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.h index 4f0d59062..0dbcc175a 100644 --- a/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.h +++ b/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.h @@ -132,6 +132,10 @@ public: static CppUnit::Test* suite(); private: + typedef Poco::Data::ODBC::Utility::DriverMap Drivers; + typedef Poco::SharedPtr SessionPtr; + typedef Poco::SharedPtr ExecPtr; + void dropObject(const std::string& type, const std::string& name); void recreatePersonTable(); void recreatePersonBLOBTable(); @@ -154,11 +158,12 @@ private: /// modify the function and recompile. /// Alternative is direct database configuration for PL/pgSQL usage. - static Poco::Data::ODBC::Utility::DriverMap _drivers; + static Drivers _drivers; static std::string _dbConnString; - static Poco::SharedPtr _pSession; - static Poco::SharedPtr _pExecutor; - static const bool bindValues[8]; + static SessionPtr _pSession; + static ExecPtr _pExecutor; + static const bool bindValues[8]; + static const std::string libDir; /// Varible determining the location of the library directory /// on the database installation system. diff --git a/Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp b/Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp index 20722fa6b..1c9a359a2 100644 --- a/Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp @@ -51,21 +51,22 @@ using namespace Poco::Data; -using Poco::Data::ODBC::Utility; -using Poco::Data::ODBC::ConnectionException; -using Poco::Data::ODBC::StatementException; -using Poco::Data::ODBC::StatementDiagnostics; +using ODBC::Utility; +using ODBC::ConnectionException; +using ODBC::StatementException; +using ODBC::StatementDiagnostics; using Poco::format; using Poco::Tuple; using Poco::DateTime; using Poco::NotFoundException; -const bool ODBCSQLServerTest::bindValues[8] = {true, true, true, false, false, true, false, false}; -Poco::SharedPtr ODBCSQLServerTest::_pSession = 0; -Poco::SharedPtr ODBCSQLServerTest::_pExecutor = 0; -std::string ODBCSQLServerTest::_dbConnString; -Poco::Data::ODBC::Utility::DriverMap ODBCSQLServerTest::_drivers; +ODBCSQLServerTest::SessionPtr ODBCSQLServerTest::_pSession = 0; +ODBCSQLServerTest::ExecPtr ODBCSQLServerTest::_pExecutor = 0; +std::string ODBCSQLServerTest::_dbConnString; +ODBCSQLServerTest::Drivers ODBCSQLServerTest::_drivers; +const bool ODBCSQLServerTest::bindValues[8] = + {true, true, true, false, false, true, false, false}; ODBCSQLServerTest::ODBCSQLServerTest(const std::string& name): diff --git a/Data/ODBC/testsuite/src/ODBCSQLServerTest.h b/Data/ODBC/testsuite/src/ODBCSQLServerTest.h index c05c2cce1..295327749 100644 --- a/Data/ODBC/testsuite/src/ODBCSQLServerTest.h +++ b/Data/ODBC/testsuite/src/ODBCSQLServerTest.h @@ -134,6 +134,10 @@ public: static CppUnit::Test* suite(); private: + typedef Poco::Data::ODBC::Utility::DriverMap Drivers; + typedef Poco::SharedPtr SessionPtr; + typedef Poco::SharedPtr ExecPtr; + void dropObject(const std::string& type, const std::string& name); void recreatePersonTable(); void recreatePersonBLOBTable(); @@ -149,10 +153,10 @@ private: static bool init(const std::string& driver, const std::string& dsn); static bool canConnect(const std::string& driver, const std::string& dsn); - static Poco::Data::ODBC::Utility::DriverMap _drivers; + static Drivers _drivers; static std::string _dbConnString; - static Poco::SharedPtr _pSession; - static Poco::SharedPtr _pExecutor; + static SessionPtr _pSession; + static ExecPtr _pExecutor; static const bool bindValues[8]; }; diff --git a/Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp b/Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp index c66bf9aa5..97572176c 100644 --- a/Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp @@ -49,19 +49,20 @@ using namespace Poco::Data; -using Poco::Data::ODBC::Utility; -using Poco::Data::ODBC::ConnectionException; -using Poco::Data::ODBC::StatementException; -using Poco::Data::ODBC::StatementDiagnostics; +using ODBC::Utility; +using ODBC::ConnectionException; +using ODBC::StatementException; +using ODBC::StatementDiagnostics; using Poco::format; using Poco::NotFoundException; -const bool ODBCSQLiteTest::bindValues[8] = {true, true, true, false, false, true, false, false}; -Poco::SharedPtr ODBCSQLiteTest::_pSession = 0; -Poco::SharedPtr ODBCSQLiteTest::_pExecutor = 0; -std::string ODBCSQLiteTest::_dbConnString; -Poco::Data::ODBC::Utility::DriverMap ODBCSQLiteTest::_drivers; +ODBCSQLiteTest::SessionPtr ODBCSQLiteTest::_pSession = 0; +ODBCSQLiteTest::ExecPtr ODBCSQLiteTest::_pExecutor = 0; +std::string ODBCSQLiteTest::_dbConnString; +ODBCSQLiteTest::Drivers ODBCSQLiteTest::_drivers; +const bool ODBCSQLiteTest::bindValues[8] = + {true, true, true, false, false, true, false, false}; ODBCSQLiteTest::ODBCSQLiteTest(const std::string& name): diff --git a/Data/ODBC/testsuite/src/ODBCSQLiteTest.h b/Data/ODBC/testsuite/src/ODBCSQLiteTest.h index 14756718b..9c6ace94d 100644 --- a/Data/ODBC/testsuite/src/ODBCSQLiteTest.h +++ b/Data/ODBC/testsuite/src/ODBCSQLiteTest.h @@ -128,6 +128,10 @@ public: static CppUnit::Test* suite(); private: + typedef Poco::Data::ODBC::Utility::DriverMap Drivers; + typedef Poco::SharedPtr SessionPtr; + typedef Poco::SharedPtr ExecPtr; + void dropObject(const std::string& type, const std::string& name); void recreatePersonTable(); void recreatePersonBLOBTable(); @@ -142,11 +146,11 @@ private: static bool init(const std::string& driver, const std::string& dsn); static bool canConnect(const std::string& driver, const std::string& dsn); - static Poco::Data::ODBC::Utility::DriverMap _drivers; + static Drivers _drivers; static std::string _dbConnString; - static Poco::SharedPtr _pSession; - static Poco::SharedPtr _pExecutor; - static const bool bindValues[8]; + static SessionPtr _pSession; + static ExecPtr _pExecutor; + static const bool bindValues[8]; }; diff --git a/Data/ODBC/testsuite/src/ODBCTestSuite.cpp b/Data/ODBC/testsuite/src/ODBCTestSuite.cpp index eafd895fb..c3e52dc89 100644 --- a/Data/ODBC/testsuite/src/ODBCTestSuite.cpp +++ b/Data/ODBC/testsuite/src/ODBCTestSuite.cpp @@ -56,16 +56,19 @@ CppUnit::Test* ODBCTestSuite::suite() // nativeError=160 // System error 127 is "The specified procedure could not be found." // - // 2) When Oracle test is loaded after DB2, the test application does not exit cleanly. - // All tests pass, though. + // Workaround is to connect to DB2 after connecting to PostgreSQL. // - // Workaround is to connect to DB2 after connecting to PostgreSQL and Oracle. - // The reason causing these errors is not known. + // 2) When Oracle driver is found, but no tests executed, the test application does not exit cleanly. + // + // Workaround is to run barebone ODBC test upon initialization of Oracle test. + // (see ODBCOracleTest::init()) + // + // The reason causing the above errors is not known at this time. - addTest(pSuite, ODBCOracleTest::suite()); addTest(pSuite, ODBCPostgreSQLTest::suite()); addTest(pSuite, ODBCDB2Test::suite()); addTest(pSuite, ODBCMySQLTest::suite()); + addTest(pSuite, ODBCOracleTest::suite()); addTest(pSuite, ODBCSQLiteTest::suite()); addTest(pSuite, ODBCSQLServerTest::suite()); #if defined(POCO_OS_FAMILY_WINDOWS) diff --git a/Data/ODBC/testsuite/src/SQLExecutor.cpp b/Data/ODBC/testsuite/src/SQLExecutor.cpp index ddba66d23..d2b496cda 100644 --- a/Data/ODBC/testsuite/src/SQLExecutor.cpp +++ b/Data/ODBC/testsuite/src/SQLExecutor.cpp @@ -56,12 +56,12 @@ using namespace Poco::Data; -using Poco::Data::ODBC::Utility; -using Poco::Data::ODBC::Preparation; -using Poco::Data::ODBC::ConnectionException; -using Poco::Data::ODBC::StatementException; -using Poco::Data::ODBC::DataTruncatedException; -using Poco::Data::ODBC::StatementDiagnostics; +using ODBC::Utility; +using ODBC::Preparation; +using ODBC::ConnectionException; +using ODBC::StatementException; +using ODBC::DataTruncatedException; +using ODBC::StatementDiagnostics; using Poco::format; using Poco::Tuple; using Poco::Any; @@ -1832,6 +1832,12 @@ void SQLExecutor::dateTime() catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } assert (res == born); + + Statement stmt = (*_pSession << "SELECT Born FROM Person", now); + RecordSet rset(stmt); + + res = rset["Born"].convert(); + assert (res == born); } diff --git a/Data/include/Poco/Data/BLOB.h b/Data/include/Poco/Data/BLOB.h index dac474013..f1c447353 100644 --- a/Data/include/Poco/Data/BLOB.h +++ b/Data/include/Poco/Data/BLOB.h @@ -294,6 +294,31 @@ public: throw Poco::BadCastException(); } + void convert(Poco::Timestamp& val) const + { + throw Poco::BadCastException(); + } + + void convert(Poco::DateTime& val) const + { + throw Poco::BadCastException(); + } + + void convert(Poco::LocalDateTime& val) const + { + throw Poco::BadCastException(); + } + + bool isArray() const + { + return false; + } + + virtual bool isStruct() const + { + return false; + } + void convert(std::string& val) const { val.assign(_val.begin(), _val.end()); diff --git a/Data/src/RecordSet.cpp b/Data/src/RecordSet.cpp index 7a85abd27..2783090b3 100644 --- a/Data/src/RecordSet.cpp +++ b/Data/src/RecordSet.cpp @@ -36,6 +36,10 @@ #include "Poco/Data/RecordSet.h" #include "Poco/Data/Session.h" +#include "Poco/DateTime.h" + + +using Poco::DateTime; namespace Poco { @@ -77,18 +81,19 @@ DynamicAny RecordSet::value(std::size_t col, std::size_t row) const switch (columnType(col)) { case MetaColumn::FDT_BOOL: - case MetaColumn::FDT_INT8: return value(col, row); - case MetaColumn::FDT_UINT8: return value(col, row); - case MetaColumn::FDT_INT16: return value(col, row); - case MetaColumn::FDT_UINT16: return value(col, row); - case MetaColumn::FDT_INT32: return value(col, row); - case MetaColumn::FDT_UINT32: return value(col, row); - case MetaColumn::FDT_INT64: return value(col, row); - case MetaColumn::FDT_UINT64: return value(col, row); - case MetaColumn::FDT_FLOAT: return value(col, row); - case MetaColumn::FDT_DOUBLE: return value(col, row); - case MetaColumn::FDT_STRING: return value(col, row); - case MetaColumn::FDT_BLOB: return value(col, row); + case MetaColumn::FDT_INT8: return value(col, row); + case MetaColumn::FDT_UINT8: return value(col, row); + case MetaColumn::FDT_INT16: return value(col, row); + case MetaColumn::FDT_UINT16: return value(col, row); + case MetaColumn::FDT_INT32: return value(col, row); + case MetaColumn::FDT_UINT32: return value(col, row); + case MetaColumn::FDT_INT64: return value(col, row); + case MetaColumn::FDT_UINT64: return value(col, row); + case MetaColumn::FDT_FLOAT: return value(col, row); + case MetaColumn::FDT_DOUBLE: return value(col, row); + case MetaColumn::FDT_STRING: return value(col, row); + case MetaColumn::FDT_BLOB: return value(col, row); + case MetaColumn::FDT_TIMESTAMP: return value(col, row); default: throw Poco::InvalidArgumentException("Data type not supported."); } @@ -100,18 +105,19 @@ DynamicAny RecordSet::value(const std::string& name, std::size_t row) const switch (columnType(name)) { case MetaColumn::FDT_BOOL: - case MetaColumn::FDT_INT8: return value(name, row); - case MetaColumn::FDT_UINT8: return value(name, row); - case MetaColumn::FDT_INT16: return value(name, row); - case MetaColumn::FDT_UINT16: return value(name, row); - case MetaColumn::FDT_INT32: return value(name, row); - case MetaColumn::FDT_UINT32: return value(name, row); - case MetaColumn::FDT_INT64: return value(name, row); - case MetaColumn::FDT_UINT64: return value(name, row); - case MetaColumn::FDT_FLOAT: return value(name, row); - case MetaColumn::FDT_DOUBLE: return value(name, row); - case MetaColumn::FDT_STRING: return value(name, row); - case MetaColumn::FDT_BLOB: return value(name, row); + case MetaColumn::FDT_INT8: return value(name, row); + case MetaColumn::FDT_UINT8: return value(name, row); + case MetaColumn::FDT_INT16: return value(name, row); + case MetaColumn::FDT_UINT16: return value(name, row); + case MetaColumn::FDT_INT32: return value(name, row); + case MetaColumn::FDT_UINT32: return value(name, row); + case MetaColumn::FDT_INT64: return value(name, row); + case MetaColumn::FDT_UINT64: return value(name, row); + case MetaColumn::FDT_FLOAT: return value(name, row); + case MetaColumn::FDT_DOUBLE: return value(name, row); + case MetaColumn::FDT_STRING: return value(name, row); + case MetaColumn::FDT_BLOB: return value(name, row); + case MetaColumn::FDT_TIMESTAMP: return value(name, row); default: throw Poco::InvalidArgumentException("Data type not supported."); } diff --git a/Data/testsuite/src/SessionImpl.cpp b/Data/testsuite/src/SessionImpl.cpp index 50d69ddea..1893f3924 100644 --- a/Data/testsuite/src/SessionImpl.cpp +++ b/Data/testsuite/src/SessionImpl.cpp @@ -91,6 +91,12 @@ bool SessionImpl::isConnected() } +bool SessionImpl::isTransaction() +{ + return false; +} + + bool SessionImpl::getConnected(const std::string& name) { return _connected; diff --git a/Data/testsuite/src/SessionImpl.h b/Data/testsuite/src/SessionImpl.h index 075036a07..ae0fd86df 100644 --- a/Data/testsuite/src/SessionImpl.h +++ b/Data/testsuite/src/SessionImpl.h @@ -75,6 +75,9 @@ public: /// Returns true if session is connected to the database, /// false otherwise. + bool isTransaction(); + /// Returns true iff a transaction is a transaction is in progress, false otherwise. + void setConnected(const std::string& name, bool value); bool getConnected(const std::string& name); /// Sets/gets the connected property.