added new memeber SqlState to PostgreSQLException and made use of it. (#4099)

* added new memeber SqlState to PostgreSQLException and made use of it in StatementExecutor

* Added test case testSqlState

* fixed nameing convention errors. fixed bug in PostgreSQLException::PostgreSQLException regarding null termination of _sqlState data member
This commit is contained in:
omerbrandis
2023-10-20 18:44:04 +03:00
committed by GitHub
parent 542b814f27
commit 3793c0a515
5 changed files with 77 additions and 7 deletions

View File

@@ -765,6 +765,20 @@ void PostgreSQLTest::testReconnect()
}
void PostgreSQLTest::testSqlState()
{
if (!_pSession) fail ("Test not available.");
try
{
*_pSession << "syntax error", now;
}
catch (const Poco::Data::PostgreSQL::PostgreSQLException & exception)
{
assertTrue(exception.sqlState() == std::string("42601"));
}
}
void PostgreSQLTest::testNullableInt()
{
if (!_pSession) fail ("Test not available.");
@@ -1271,6 +1285,7 @@ CppUnit::Test* PostgreSQLTest::suite()
CppUnit_addTest(pSuite, PostgreSQLTest, testNullableInt);
CppUnit_addTest(pSuite, PostgreSQLTest, testNullableString);
CppUnit_addTest(pSuite, PostgreSQLTest, testTupleWithNullable);
CppUnit_addTest(pSuite, PostgreSQLTest, testSqlState);
CppUnit_addTest(pSuite, PostgreSQLTest, testBinarySimpleAccess);
CppUnit_addTest(pSuite, PostgreSQLTest, testBinaryComplexType);

View File

@@ -27,8 +27,8 @@ class PostgreSQLTest: public CppUnit::TestCase
///
/// Driver | DB | OS
/// ----------------+---------------------------+------------------------------------------
/// 03.51.12.00 | PostgreSQL 9.3.1.0(18) | Mac OSX 10.9.1
///
/// 03.51.12.00 | PostgreSQL 9.3.1.0(18) | Mac OSX 10.9.1
/// | PostgreSQL 15.3 | Ubuntu 16.04
{
public:
@@ -113,6 +113,8 @@ public:
void testReconnect();
void testSqlState();
void setUp();
void tearDown();