Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3445,6 +3445,11 @@ bool SQLTagStore::ResetAndBindStatement(
Environment* env,
StatementSync* stmt,
const FunctionCallbackInfo<Value>& args) {
if (stmt->IsFinalized()) {
THROW_ERR_INVALID_STATE(env, "statement has been finalized");
Comment thread
lazerg marked this conversation as resolved.
Outdated
return false;
}

Isolate* isolate = env->isolate();
int r = stmt->ResetStatement();
CHECK_ERROR_OR_THROW(isolate, stmt->db_.get(), r, SQLITE_OK, false);
Expand Down
14 changes: 14 additions & 0 deletions test/parallel/test-sqlite-template-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ test('rejects parameters outside of template expressions', () => {
ldb.close();
});

test('rejects queries that contain no statement', () => {
const expectedError = {
code: 'ERR_INVALID_STATE',
message: /statement has been finalized/,
};

for (const method of ['run', 'get', 'all', 'iterate']) {
assert.throws(() => {
// eslint-disable-next-line no-unused-expressions
sql[method]`-- comment`;
}, expectedError);
}
});

test('TagStore capacity, size, and clear', () => {
assert.strictEqual(sql.capacity, 10);
assert.strictEqual(sql.size, 0);
Expand Down
Loading