diff options
author | 2023-02-27 20:29:00 -0600 | |
---|---|---|
committer | 2023-02-27 18:29:00 -0800 | |
commit | ae35f17a99c96372bcdd519e8c5202e08a419379 (patch) | |
tree | e12ef96ed39554e9a5dabf877f839c38b670887d /test/bun.js/sqlite.test.js | |
parent | 062b5565a7a00aa7f85b404eb45b6c8be6d7b52b (diff) | |
download | bun-ae35f17a99c96372bcdd519e8c5202e08a419379.tar.gz bun-ae35f17a99c96372bcdd519e8c5202e08a419379.tar.zst bun-ae35f17a99c96372bcdd519e8c5202e08a419379.zip |
fix(bun:sqlite): fix `sqliteDb.run(' ')` throwing `not an error` (#2226)
Diffstat (limited to 'test/bun.js/sqlite.test.js')
-rw-r--r-- | test/bun.js/sqlite.test.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/bun.js/sqlite.test.js b/test/bun.js/sqlite.test.js index 3120283f4..408fa5a26 100644 --- a/test/bun.js/sqlite.test.js +++ b/test/bun.js/sqlite.test.js @@ -504,3 +504,26 @@ it("latin1 supplement chars", () => { }, ]); }); + +describe("Database.run", () => { + it("should not throw error `not an error` when provided query containing only whitespace", () => { + const db = Database.open(":memory:"); + db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)"); + + expect(db[Symbol.for("Bun.Database.cache.count")]).toBe(0); + + var q = db.query("SELECT * FROM test WHERE name = ?"); + expect(q.get("Hello") === null).toBe(true); + + db.exec('INSERT INTO test (name) VALUES ("Hello")'); + db.exec('INSERT INTO test (name) VALUES ("World")'); + + try { + db.run(" "); + expect(true).toBeFalsy(); + } catch (e) { + expect(e.message).not.toBe("not an error"); + expect(e.message).toBe("Query contained no valid SQL statement; likely empty query."); + } + }); +}); |