fix(Data::Binder: Skip reset for null Binder #4109

This commit is contained in:
Alex Fabijanic 2023-08-15 21:23:54 +02:00
parent b90316f949
commit 9a734674ed
2 changed files with 14 additions and 13 deletions

View File

@ -256,7 +256,7 @@ SQLiteTest::~SQLiteTest()
void SQLiteTest::testBind()
{
int f1 = -1;
std::vector<int> vf1;
Session session(Poco::Data::SQLite::Connector::KEY, "dummy.db");
session << "DROP TABLE IF EXISTS test", now;
session << "CREATE TABLE test (f1 INTEGER)", now;
@ -265,12 +265,17 @@ void SQLiteTest::testBind()
statement << "INSERT INTO test(f1) VALUES(?)";
statement.addBind(Poco::Data::Keywords::bind(1, "f1"));
statement.execute();
session << "SELECT f1 FROM test", into(f1), now;
assertTrue (f1 == 1);
session << "SELECT f1 FROM test", into(vf1), now;
assertTrue (vf1.size() == 1);
assertTrue (vf1[0] == 1);
statement.removeBind("f1");
statement.addBind(Poco::Data::Keywords::bind(2, "f1"));
statement.execute();
assertTrue (f1 == 2);
vf1.clear();
session << "SELECT f1 FROM test", into(vf1), now;
assertTrue (vf1.size() == 2);
assertTrue (vf1[0] == 1);
assertTrue (vf1[1] == 2);
}
@ -3501,6 +3506,7 @@ CppUnit::Test* SQLiteTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SQLiteTest");
CppUnit_addTest(pSuite, SQLiteTest, testBind);
CppUnit_addTest(pSuite, SQLiteTest, testBinding);
CppUnit_addTest(pSuite, SQLiteTest, testZeroRows);
CppUnit_addTest(pSuite, SQLiteTest, testSimpleAccess);

View File

@ -98,8 +98,7 @@ public:
{
_bound = false;
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
if (pBinder) pBinder->reset();
}
private:
@ -168,12 +167,10 @@ public:
{
_bound = false;
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
if (pBinder) pBinder->reset();
}
private:
//typedef typename TypeWrapper<T>::TYPE ValueType;
ValPtr _pVal;
bool _bound;
};
@ -230,8 +227,7 @@ public:
{
_bound = false;
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
if (pBinder) pBinder->reset();
}
private:
@ -292,8 +288,7 @@ public:
{
_bound = false;
AbstractBinder::Ptr pBinder = getBinder();
poco_assert_dbg (!pBinder.isNull());
pBinder->reset();
if (pBinder) pBinder->reset();
}
private: