File tree 3 files changed +23
-0
lines changed
3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -629,6 +629,9 @@ class Statement
629
629
return mbDone;
630
630
}
631
631
632
+ // / Return the number of bind parameters in the statement
633
+ int getBindParameterCount () const noexcept ;
634
+
632
635
// / Return the numeric result code for the most recent failed API call (if any).
633
636
int getErrorCode () const noexcept ; // nothrow
634
637
// / 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
391
391
return (*iIndex).second ;
392
392
}
393
393
394
+ int Statement::getBindParameterCount () const noexcept
395
+ {
396
+ return sqlite3_bind_parameter_count (mStmtPtr );
397
+ }
398
+
394
399
// Return the numeric result code for the most recent failed API call (if any).
395
400
int Statement::getErrorCode () const noexcept // nothrow
396
401
{
Original file line number Diff line number Diff line change @@ -831,3 +831,18 @@ TEST(Statement, bind64bitsLong) {
831
831
EXPECT_EQ (4294967297L , query.getColumn (0 ).getInt64 ());
832
832
}
833
833
#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