Skip to content

Conversation

smith-xyz
Copy link

Summary

Adds expandedSql property to Statement objects for debugging SQL with/without bound parameters.

Description

Exposes SQLite's sqlite3_expanded_sql() as a readonly property accessor on Statement. Returns the SQL query with parameter values filled in, useful for debugging and logging actual queries.

Example Usage

const stmt = db.prepare("SELECT * FROM users WHERE id = ?");
stmt.get(123, function(err, row) {
  console.log(stmt.expandedSql); 
  // "SELECT * FROM users WHERE id = 123"
});

Changes

  • Added ExpandedSQLGetter() N-API property accessor to Statement class
  • Proper memory management with sqlite3_free()
  • TypeScript definitions updated
  • Tests added

Closes #1678

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Utilize sqlite3_expanded_sql to retrieve sql statements with bindings

1 participant