mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
fix(ext/node): DatabaseSync#exec
should execute batch statements (#28053)
Fixes https://github.com/denoland/deno/issues/28050
This commit is contained in:
parent
acdc7dcdcf
commit
196ceb76bb
2 changed files with 14 additions and 2 deletions
|
@ -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(())
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue