diff --git a/bindings/javascript/__test__/better-sqlite3.spec.mjs b/bindings/javascript/__test__/better-sqlite3.spec.mjs index c88290b53..9f5aaba93 100644 --- a/bindings/javascript/__test__/better-sqlite3.spec.mjs +++ b/bindings/javascript/__test__/better-sqlite3.spec.mjs @@ -96,18 +96,7 @@ inMemoryTest.both("Statment.iterate() should correctly return an iterable object } }); -inMemoryTest.both("Empty prepared statement should throw", async (t) => { - const db = t.context.db; - t.throws( - () => { - db.prepare(""); - }, - { any: true } - ); -}); - -inMemoryTest.onlySqlitePasses("Empty prepared statement should throw the correct error", async (t) => { - // the previous test can be removed once this one passes in Turso +inMemoryTest.both("Empty prepared statement should throw the correct error", async (t) => { const db = t.context.db; t.throws( () => { diff --git a/bindings/javascript/wrapper.js b/bindings/javascript/wrapper.js index 9d513f514..57235d8e5 100644 --- a/bindings/javascript/wrapper.js +++ b/bindings/javascript/wrapper.js @@ -77,6 +77,10 @@ class Database { * @param {string} sql - The SQL statement string to prepare. */ prepare(sql) { + if (!sql) { + throw new RangeError('The supplied SQL string contains no statements'); + } + try { return new Statement(this.db.prepare(sql), this); } catch (err) {