Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/SQLiteCpp/Statement.h
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,10 @@ class Statement
{
return mQuery;
}

// Return a UTF-8 string containing the SQL text of prepared statement with bound parameters expanded.
std::string getExtendedSQL();

/// Return the number of columns in the result set returned by the prepared statement
inline int getColumnCount() const
{
Expand Down
7 changes: 7 additions & 0 deletions src/Statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,17 +401,24 @@ int Statement::getErrorCode() const noexcept // nothrow
{
return sqlite3_errcode(mStmtPtr);
}

// Return the extended numeric result code for the most recent failed API call (if any).
int Statement::getExtendedErrorCode() const noexcept // nothrow
{
return sqlite3_extended_errcode(mStmtPtr);
}

// Return UTF-8 encoded English language explanation of the most recent failed API call (if any).
const char* Statement::getErrorMsg() const noexcept // nothrow
{
return sqlite3_errmsg(mStmtPtr);
}

// Return a UTF-8 string containing the SQL text of prepared statement with bound parameters expanded.
std::string Statement::getExtendedSQL() {
return sqlite3_expanded_sql(mStmtPtr);
}

////////////////////////////////////////////////////////////////////////////////
// Internal class : shared pointer to the sqlite3_stmt SQLite Statement Object
////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions tests/Statement_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ TEST(Statement, bindings) {
insert.bind(1, text);
insert.bind(2, integer);
insert.bind(3, dbl);
EXPECT_EQ(insert.getExtendedSQL(), "INSERT INTO test VALUES (NULL, 'first', -123, 0.123)");
EXPECT_EQ(1, insert.exec());
EXPECT_EQ(SQLITE_DONE, db.getErrorCode());

Expand Down