mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 17:30:44 +02:00
ODBC null value support and tests (tested win32 all & Linux PostgreSQL)
This commit is contained in:
@@ -864,6 +864,32 @@ void ODBCSQLServerTest::testInternalStorageType()
|
||||
}
|
||||
|
||||
|
||||
void ODBCSQLServerTest::testNull()
|
||||
{
|
||||
if (!_pSession) fail ("Test not available.");
|
||||
|
||||
// test for NOT NULL violation exception
|
||||
for (int i = 0; i < 8;)
|
||||
{
|
||||
recreateNullsTable("NOT NULL");
|
||||
_pSession->setFeature("autoBind", bindValues[i]);
|
||||
_pSession->setFeature("autoExtract", bindValues[i+1]);
|
||||
_pExecutor->notNulls("23000");
|
||||
i += 2;
|
||||
}
|
||||
|
||||
// test for null insertion
|
||||
for (int i = 0; i < 8;)
|
||||
{
|
||||
recreateNullsTable();
|
||||
_pSession->setFeature("autoBind", bindValues[i]);
|
||||
_pSession->setFeature("autoExtract", bindValues[i+1]);
|
||||
_pExecutor->nulls();
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ODBCSQLServerTest::testStoredProcedure()
|
||||
{
|
||||
for (int k = 0; k < 8;)
|
||||
@@ -1137,6 +1163,18 @@ void ODBCSQLServerTest::recreateVectorsTable()
|
||||
}
|
||||
|
||||
|
||||
void ODBCSQLServerTest::recreateNullsTable(const std::string& notNull)
|
||||
{
|
||||
dropObject("TABLE", "NullTest");
|
||||
try { *_pSession << format("CREATE TABLE NullTest (i INTEGER %s, r FLOAT %s, v VARCHAR(30) %s)",
|
||||
notNull,
|
||||
notNull,
|
||||
notNull), now; }
|
||||
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail ("recreateNullsTable()"); }
|
||||
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail ("recreateNullsTable()"); }
|
||||
}
|
||||
|
||||
|
||||
bool ODBCSQLServerTest::canConnect(const std::string& driver, const std::string& dsn)
|
||||
{
|
||||
Utility::DriverMap::iterator itDrv = _drivers.begin();
|
||||
@@ -1282,6 +1320,7 @@ CppUnit::Test* ODBCSQLServerTest::suite()
|
||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testStoredFunction);
|
||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInternalExtraction);
|
||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testInternalStorageType);
|
||||
CppUnit_addTest(pSuite, ODBCSQLServerTest, testNull);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user