mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix(ext/node): implement SQLite Session API (#27909)
https://nodejs.org/api/sqlite.html#class-session --------- Signed-off-by: Divy Srivastava <dj.srivastava23@gmail.com>
This commit is contained in:
parent
98339cf327
commit
28834a89bb
7 changed files with 250 additions and 5 deletions
|
@ -77,6 +77,27 @@ Deno.test("[node/sqlite] StatementSync read bigints are supported", () => {
|
|||
assertEquals(stmt.expandedSQL, "SELECT * FROM data");
|
||||
});
|
||||
|
||||
Deno.test("[node/sqlite] createSession and changesets", () => {
|
||||
const db = new DatabaseSync(":memory:");
|
||||
const session = db.createSession();
|
||||
|
||||
db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)");
|
||||
db.exec("INSERT INTO test (name) VALUES ('foo')");
|
||||
|
||||
assert(session.changeset() instanceof Uint8Array);
|
||||
assert(session.patchset() instanceof Uint8Array);
|
||||
|
||||
assert(session.changeset().byteLength > 0);
|
||||
assert(session.patchset().byteLength > 0);
|
||||
|
||||
session.close();
|
||||
|
||||
// Use after close shoud throw.
|
||||
assertThrows(() => session.changeset(), Error, "Session is already closed");
|
||||
// Close after close should throw.
|
||||
assertThrows(() => session.close(), Error, "Session is already closed");
|
||||
});
|
||||
|
||||
Deno.test("[node/sqlite] StatementSync integer too large", () => {
|
||||
const db = new DatabaseSync(":memory:");
|
||||
db.exec("CREATE TABLE data(key INTEGER PRIMARY KEY);");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue