mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(ext/node): expose sqlite changeset constants (#27992)
https://nodejs.org/api/sqlite.html#sqliteconstants
This commit is contained in:
parent
78fceb4a33
commit
4a2b8fc22d
2 changed files with 17 additions and 4 deletions
|
@ -2,8 +2,21 @@
|
|||
|
||||
import { DatabaseSync } from "ext:core/ops";
|
||||
|
||||
export const constants = {
|
||||
SQLITE_CHANGESET_OMIT: 0,
|
||||
SQLITE_CHANGESET_REPLACE: 1,
|
||||
SQLITE_CHANGESET_ABORT: 2,
|
||||
|
||||
SQLITE_CHANGESET_DATA: 1,
|
||||
SQLITE_CHANGESET_NOTFOUND: 2,
|
||||
SQLITE_CHANGESET_CONFLICT: 3,
|
||||
SQLITE_CHANGESET_CONSTRAINT: 4,
|
||||
SQLITE_CHANGESET_FOREIGN_KEY: 5,
|
||||
};
|
||||
|
||||
export { DatabaseSync };
|
||||
|
||||
export default {
|
||||
constants,
|
||||
DatabaseSync,
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018-2025 the Deno authors. MIT license.
|
||||
import { DatabaseSync } from "node:sqlite";
|
||||
import sqlite, { DatabaseSync } from "node:sqlite";
|
||||
import { assert, assertEquals, assertThrows } from "@std/assert";
|
||||
|
||||
const tempDir = Deno.makeTempDirSync();
|
||||
|
@ -173,9 +173,9 @@ Deno.test("[node/sqlite] applyChangeset across databases", () => {
|
|||
|
||||
const changeset = session.changeset();
|
||||
targetDb.applyChangeset(changeset, {
|
||||
filter(e) {
|
||||
return e === "data";
|
||||
},
|
||||
filter: (e) => e === "data",
|
||||
// @ts-ignore: types are not up to date
|
||||
onConflict: () => sqlite.constants.SQLITE_CHANGESET_ABORT,
|
||||
});
|
||||
|
||||
const stmt = targetDb.prepare("SELECT * FROM data");
|
||||
|
|
Loading…
Add table
Reference in a new issue