File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -629,6 +629,9 @@ class Statement
629629 return mbDone;
630630 }
631631
632+ // / Return the number of bind parameters in the statement
633+ int getBindParameterCount () const noexcept ;
634+
632635 // / Return the numeric result code for the most recent failed API call (if any).
633636 int getErrorCode () const noexcept ; // nothrow
634637 // / Return the extended numeric result code for the most recent failed API call (if any).
Original file line number Diff line number Diff line change @@ -391,6 +391,11 @@ int Statement::getColumnIndex(const char* apName) const
391391 return (*iIndex).second ;
392392}
393393
394+ int Statement::getBindParameterCount () const noexcept
395+ {
396+ return sqlite3_bind_parameter_count (mStmtPtr );
397+ }
398+
394399// Return the numeric result code for the most recent failed API call (if any).
395400int Statement::getErrorCode () const noexcept // nothrow
396401{
Original file line number Diff line number Diff line change @@ -831,3 +831,18 @@ TEST(Statement, bind64bitsLong) {
831831 EXPECT_EQ (4294967297L , query.getColumn (0 ).getInt64 ());
832832}
833833#endif
834+
835+ TEST (Statement, getBindParameterCount) {
836+ // Create a new database
837+ SQLite::Database db (" :memory:" , SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
838+ EXPECT_EQ (0 , db.exec (" CREATE TABLE test (id INTEGER PRIMARY KEY, msg TEXT)" ));
839+
840+ SQLite::Statement query (db, " SELECT id, msg FROM test where id = ?" );
841+ EXPECT_EQ (1 , query.getBindParameterCount ());
842+
843+ SQLite::Statement query2 (db, " SELECT id, msg FROM test where id = ? and msg = ?" );
844+ EXPECT_EQ (2 , query2.getBindParameterCount ());
845+
846+ SQLite::Statement query3 (db, " SELECT id, msg FROM test" );
847+ EXPECT_EQ (0 , query3.getBindParameterCount ());
848+ }
You can’t perform that action at this time.
0 commit comments