Skip to content

Commit

Permalink
enh(ODBC): ODBC: DataFormatException getting Time value from SQL Server
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f authored Nov 20, 2024
1 parent 1215b21 commit 21f93e3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Data/ODBC/src/ODBCMetaColumn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions Data/ODBC/testsuite/src/ODBCSQLServerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class ODBCSQLServerTest: public ODBCTest
void testStoredProcedureReturn();
void testStoredFunction() override;

void testSQLServerTime();

static CppUnit::Test* suite();

private:
Expand Down

0 comments on commit 21f93e3

Please sign in to comment.