fix(ext/node): DatabaseSync#exec should execute batch statements (#28053)

Fixes https://github.com/denoland/deno/issues/28050
This commit is contained in:
Divy Srivastava 2025-02-11 19:52:33 +05:30 committed by GitHub
parent acdc7dcdcf
commit 196ceb76bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View file

@ -166,8 +166,7 @@ impl DatabaseSync {
let db = self.conn.borrow();
let db = db.as_ref().ok_or(SqliteError::InUse)?;
let mut stmt = db.prepare_cached(sql)?;
stmt.raw_execute()?;
db.execute_batch(sql)?;
Ok(())
}

View file

@ -184,3 +184,16 @@ Deno.test("[node/sqlite] applyChangeset across databases", () => {
{ key: 2, value: "world", __proto__: null },
]);
});
Deno.test("[node/sqlite] exec should execute batch statements", () => {
const db = new DatabaseSync(":memory:");
db.exec(`CREATE TABLE one(id int PRIMARY KEY) STRICT;
CREATE TABLE two(id int PRIMARY KEY) STRICT;`);
const table = db.prepare(
`SELECT name FROM sqlite_master WHERE type='table'`,
).all();
assertEquals(table.length, 2);
db.close();
});