Skip to content

fix: reject queries that contain no SQL statement - #370

Open
DaveyEke wants to merge 1 commit into
codex/prepared-statements-prfrom
fix/prepare-empty-query
Open

DaveyEke wants to merge 1 commit into
codex/prepared-statements-prfrom
fix/prepare-empty-query

Conversation

@DaveyEke

Copy link
Copy Markdown
Collaborator

sqlite3_prepare_v2 returns SQLITE_OK with a null statement when the query contains no SQL, such as an empty string or nothing but comments. SQLite's own sqlite3_exec guards for it:

if( !pStmt ){
  /* this happens for a comment or white-space */
  zSql = zLeftover;
  continue;
}

prepareStatement only checked the status code. So db.prepare('') returned a statement reporting isFinalized === true before it had ever been used, and db.execute('') reached sqlite3_step with a null statement.

The guard goes in prepareStatement so both paths report the same error.

@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-native-nitro-sqlite Ready Ready Preview Sep 20, 2026 6:16pm UTC

Request Review

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.

1 participant