mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Merge pull request #192 from jrave/bind_parameter_count
Add wrapper for bind parameter count
This commit is contained in:
commit
f1301a4a11
@ -629,6 +629,9 @@ public:
|
|||||||
return mbDone;
|
return mbDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the number of bind parameters in the statement
|
||||||
|
int getBindParameterCount() const noexcept;
|
||||||
|
|
||||||
/// Return the numeric result code for the most recent failed API call (if any).
|
/// Return the numeric result code for the most recent failed API call (if any).
|
||||||
int getErrorCode() const noexcept; // nothrow
|
int getErrorCode() const noexcept; // nothrow
|
||||||
/// Return the extended numeric result code for the most recent failed API call (if any).
|
/// Return the extended numeric result code for the most recent failed API call (if any).
|
||||||
|
@ -391,6 +391,11 @@ int Statement::getColumnIndex(const char* apName) const
|
|||||||
return (*iIndex).second;
|
return (*iIndex).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Statement::getBindParameterCount() const noexcept
|
||||||
|
{
|
||||||
|
return sqlite3_bind_parameter_count(mStmtPtr);
|
||||||
|
}
|
||||||
|
|
||||||
// Return the numeric result code for the most recent failed API call (if any).
|
// Return the numeric result code for the most recent failed API call (if any).
|
||||||
int Statement::getErrorCode() const noexcept // nothrow
|
int Statement::getErrorCode() const noexcept // nothrow
|
||||||
{
|
{
|
||||||
|
@ -831,3 +831,18 @@ TEST(Statement, bind64bitsLong) {
|
|||||||
EXPECT_EQ(4294967297L, query.getColumn(0).getInt64());
|
EXPECT_EQ(4294967297L, query.getColumn(0).getInt64());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
TEST(Statement, getBindParameterCount) {
|
||||||
|
// Create a new database
|
||||||
|
SQLite::Database db(":memory:", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
|
||||||
|
EXPECT_EQ(0, db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT)"));
|
||||||
|
|
||||||
|
SQLite::Statement query(db, "SELECT id, msg FROM test where id = ?");
|
||||||
|
EXPECT_EQ(1, query.getBindParameterCount());
|
||||||
|
|
||||||
|
SQLite::Statement query2(db, "SELECT id, msg FROM test where id = ? and msg = ?");
|
||||||
|
EXPECT_EQ(2, query2.getBindParameterCount());
|
||||||
|
|
||||||
|
SQLite::Statement query3(db, "SELECT id, msg FROM test");
|
||||||
|
EXPECT_EQ(0, query3.getBindParameterCount());
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user