mirror of
				https://github.com/pocoproject/poco.git
				synced 2025-10-27 02:53:10 +01:00 
			
		
		
		
	fix(Data::Binder: Skip reset for null Binder #4109
This commit is contained in:
		| @@ -256,7 +256,7 @@ SQLiteTest::~SQLiteTest() | |||||||
|  |  | ||||||
| void SQLiteTest::testBind() | void SQLiteTest::testBind() | ||||||
| { | { | ||||||
| 	int f1 = -1; | 	std::vector<int> vf1; | ||||||
| 	Session session(Poco::Data::SQLite::Connector::KEY, "dummy.db"); | 	Session session(Poco::Data::SQLite::Connector::KEY, "dummy.db"); | ||||||
| 	session << "DROP TABLE IF EXISTS test", now; | 	session << "DROP TABLE IF EXISTS test", now; | ||||||
| 	session << "CREATE TABLE test (f1 INTEGER)", now; | 	session << "CREATE TABLE test (f1 INTEGER)", now; | ||||||
| @@ -265,12 +265,17 @@ void SQLiteTest::testBind() | |||||||
| 	statement << "INSERT INTO test(f1) VALUES(?)"; | 	statement << "INSERT INTO test(f1) VALUES(?)"; | ||||||
| 	statement.addBind(Poco::Data::Keywords::bind(1, "f1")); | 	statement.addBind(Poco::Data::Keywords::bind(1, "f1")); | ||||||
| 	statement.execute(); | 	statement.execute(); | ||||||
| 	session << "SELECT f1 FROM test", into(f1), now; | 	session << "SELECT f1 FROM test", into(vf1), now; | ||||||
| 	assertTrue (f1 == 1); | 	assertTrue (vf1.size() == 1); | ||||||
|  | 	assertTrue (vf1[0] == 1); | ||||||
| 	statement.removeBind("f1"); | 	statement.removeBind("f1"); | ||||||
| 	statement.addBind(Poco::Data::Keywords::bind(2, "f1")); | 	statement.addBind(Poco::Data::Keywords::bind(2, "f1")); | ||||||
| 	statement.execute(); | 	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::TestSuite* pSuite = new CppUnit::TestSuite("SQLiteTest"); | ||||||
|  |  | ||||||
|  | 	CppUnit_addTest(pSuite, SQLiteTest, testBind); | ||||||
| 	CppUnit_addTest(pSuite, SQLiteTest, testBinding); | 	CppUnit_addTest(pSuite, SQLiteTest, testBinding); | ||||||
| 	CppUnit_addTest(pSuite, SQLiteTest, testZeroRows); | 	CppUnit_addTest(pSuite, SQLiteTest, testZeroRows); | ||||||
| 	CppUnit_addTest(pSuite, SQLiteTest, testSimpleAccess); | 	CppUnit_addTest(pSuite, SQLiteTest, testSimpleAccess); | ||||||
|   | |||||||
| @@ -98,8 +98,7 @@ public: | |||||||
| 	{ | 	{ | ||||||
| 		_bound = false; | 		_bound = false; | ||||||
| 		AbstractBinder::Ptr pBinder = getBinder(); | 		AbstractBinder::Ptr pBinder = getBinder(); | ||||||
| 		poco_assert_dbg (!pBinder.isNull()); | 		if (pBinder) pBinder->reset(); | ||||||
| 		pBinder->reset(); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| private: | private: | ||||||
| @@ -168,12 +167,10 @@ public: | |||||||
| 	{ | 	{ | ||||||
| 		_bound = false; | 		_bound = false; | ||||||
| 		AbstractBinder::Ptr pBinder = getBinder(); | 		AbstractBinder::Ptr pBinder = getBinder(); | ||||||
| 		poco_assert_dbg (!pBinder.isNull()); | 		if (pBinder) pBinder->reset(); | ||||||
| 		pBinder->reset(); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| private: | private: | ||||||
| 	//typedef typename TypeWrapper<T>::TYPE ValueType; |  | ||||||
| 	ValPtr _pVal; | 	ValPtr _pVal; | ||||||
| 	bool   _bound; | 	bool   _bound; | ||||||
| }; | }; | ||||||
| @@ -230,8 +227,7 @@ public: | |||||||
| 	{ | 	{ | ||||||
| 		_bound = false; | 		_bound = false; | ||||||
| 		AbstractBinder::Ptr pBinder = getBinder(); | 		AbstractBinder::Ptr pBinder = getBinder(); | ||||||
| 		poco_assert_dbg (!pBinder.isNull()); | 		if (pBinder) pBinder->reset(); | ||||||
| 		pBinder->reset(); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| private: | private: | ||||||
| @@ -292,8 +288,7 @@ public: | |||||||
| 	{ | 	{ | ||||||
| 		_bound = false; | 		_bound = false; | ||||||
| 		AbstractBinder::Ptr pBinder = getBinder(); | 		AbstractBinder::Ptr pBinder = getBinder(); | ||||||
| 		poco_assert_dbg (!pBinder.isNull()); | 		if (pBinder) pBinder->reset(); | ||||||
| 		pBinder->reset(); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| private: | private: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Alex Fabijanic
					Alex Fabijanic