mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 17:05:36 +01:00
throw on empty statement
This commit is contained in:
@@ -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(
|
||||
() => {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user