mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-14 15:05:35 +02:00
SQLite not handling parameter count mismatch correctly #2020
This commit is contained in:
@@ -427,7 +427,7 @@ void SQLiteTest::testNullCharPointer()
|
||||
bind("firstname"),
|
||||
bind("Address"), bind(pc), now;
|
||||
fail ("must fail");
|
||||
} catch (NullPointerException&) { }
|
||||
} catch (NullPointerException&) { }
|
||||
|
||||
tmp << "SELECT COUNT(*) FROM PERSON", into(count), now;
|
||||
assert (count == 1);
|
||||
@@ -466,7 +466,7 @@ void SQLiteTest::testInsertCharPointer()
|
||||
bind("firstname"),
|
||||
bind("Address"),
|
||||
bind(133132));
|
||||
|
||||
|
||||
std::free((void*) pc); pc = 0;
|
||||
assert (1 == stmt.execute());
|
||||
|
||||
@@ -2190,10 +2190,12 @@ void SQLiteTest::testAsync()
|
||||
assert (stmt1.wait() == rowCount);
|
||||
|
||||
stmt1.execute();
|
||||
try {
|
||||
try
|
||||
{
|
||||
stmt1.execute();
|
||||
fail ("must fail");
|
||||
} catch (InvalidAccessException&)
|
||||
}
|
||||
catch (InvalidAccessException&)
|
||||
{
|
||||
stmt1.wait();
|
||||
stmt1.execute();
|
||||
@@ -2206,10 +2208,12 @@ void SQLiteTest::testAsync()
|
||||
|
||||
assert (stmt.execute() == 0);
|
||||
assert (stmt.isAsync());
|
||||
try {
|
||||
try
|
||||
{
|
||||
result = stmt.executeAsync();
|
||||
fail ("must fail");
|
||||
} catch (InvalidAccessException&)
|
||||
}
|
||||
catch (InvalidAccessException&)
|
||||
{
|
||||
stmt.wait();
|
||||
result = stmt.executeAsync();
|
||||
@@ -2319,7 +2323,6 @@ void SQLiteTest::testPair()
|
||||
std::string tableName("Simpsons");
|
||||
std::pair<std::string, int> junior = std::make_pair("Junior", 12);
|
||||
std::pair<std::string, int> senior = std::make_pair("Senior", 99);
|
||||
|
||||
|
||||
int count = 0;
|
||||
std::string result;
|
||||
@@ -2329,7 +2332,6 @@ void SQLiteTest::testPair()
|
||||
tmp << "SELECT name FROM sqlite_master WHERE tbl_name=?", use(tableName), into(result), now;
|
||||
assert (result == tableName);
|
||||
|
||||
|
||||
// these are fine
|
||||
tmp << "INSERT INTO Simpsons VALUES(?, ?)", use(junior), now;
|
||||
tmp << "INSERT INTO Simpsons VALUES(?, ?)", useRef(senior), now;
|
||||
@@ -2343,7 +2345,6 @@ void SQLiteTest::testPair()
|
||||
assert (ret[0].second == 99 || ret[1].second == 99);
|
||||
assert (ret[0].first == "Junior" || ret[1].first == "Junior");
|
||||
assert (ret[0].first == "Senior" || ret[1].first == "Senior");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2500,12 +2501,12 @@ void SQLiteTest::testBindingCount()
|
||||
tmp << "CREATE TABLE Ints (int0 INTEGER)", now;
|
||||
|
||||
int i = 42;
|
||||
try { tmp << "INSERT INTO Ints VALUES (?)", now; }
|
||||
try { tmp << "INSERT INTO Ints VALUES (?)", now; fail("must fail"); }
|
||||
catch (ParameterCountMismatchException&) { }
|
||||
tmp << "INSERT INTO Ints VALUES (?)", use(i), now;
|
||||
|
||||
i = 0;
|
||||
try { tmp << "SELECT int0 from Ints where int0 = ?", into(i), now; }
|
||||
try { tmp << "SELECT int0 from Ints where int0 = ?", into(i), now; fail("must fail"); }
|
||||
catch (ParameterCountMismatchException&) { }
|
||||
tmp << "SELECT int0 from Ints where int0 = ?", bind(42), into(i), now;
|
||||
assert (42 == i);
|
||||
@@ -2513,8 +2514,8 @@ void SQLiteTest::testBindingCount()
|
||||
tmp << "DROP TABLE IF EXISTS Ints", now;
|
||||
tmp << "CREATE TABLE Ints (int0 INTEGER, int1 INTEGER, int2 INTEGER)", now;
|
||||
|
||||
try { tmp << "INSERT INTO Ints VALUES (?,?,?)", bind(42), bind(42), now; }
|
||||
catch (ParameterCountMismatchException&) { }
|
||||
try { tmp << "INSERT INTO Ints VALUES (?,?,?)", bind(42), bind(42), now; fail("must fail"); }
|
||||
catch (ParameterCountMismatchException& ex) { }
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user