enh(ODBC): ODBC: DataFormatException getting Time value from SQL Server #3801 (#4777)

This commit is contained in:
Aleksandar Fabijanic 2024-11-20 09:22:53 -06:00 committed by GitHub
parent 1215b217b5
commit 21f93e3e6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 1 deletions

View File

@ -160,7 +160,9 @@ void ODBCMetaColumn::init()
setType(MetaColumn::FDT_DATE); break;
case SQL_TYPE_TIME:
case -154: //MS SQL Server custom type SQL_SS_TIME2
#ifdef POCO_DATA_ODBC_HAVE_SQL_SERVER_EXT
case SQL_SS_TIME2: // MS SQL Server custom type
#endif
setType(MetaColumn::FDT_TIME); break;
case SQL_TYPE_TIMESTAMP:

View File

@ -836,6 +836,19 @@ void ODBCSQLServerTest::testStoredFunction()
}
void ODBCSQLServerTest::testSQLServerTime()
{
Poco::Data::Time t;
dropObject("TABLE", "TimeTestTable");
session() << "CREATE TABLE TimeTestTable (t time)", now;
session() << "INSERT INTO TimeTestTable (t) VALUES ('12:34:56')", now;
session() << "SELECT t FROM TimeTestTable", into(t), now;
std::ostringstream os;
os << t.hour() << ':' << t.minute() << ':' << t.second();
assertEqual(os.str(), "12:34:56"s);
}
void ODBCSQLServerTest::dropObject(const std::string& type, const std::string& name)
{
try
@ -1168,6 +1181,7 @@ CppUnit::Test* ODBCSQLServerTest::suite()
CppUnit_addTest(pSuite, ODBCSQLServerTest, testUnicode);
CppUnit_addTest(pSuite, ODBCSQLServerTest, testEncoding);
CppUnit_addTest(pSuite, ODBCSQLServerTest, testReconnect);
CppUnit_addTest(pSuite, ODBCSQLServerTest, testSQLServerTime);
return pSuite;
}

View File

@ -62,6 +62,8 @@ public:
void testStoredProcedureReturn();
void testStoredFunction() override;
void testSQLServerTime();
static CppUnit::Test* suite();
private: