Skip to content

Commit

Permalink
fix(ext/node): expose sqlite changeset constants (#27992)
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy authored Feb 6, 2025
1 parent 78fceb4 commit 4a2b8fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
13 changes: 13 additions & 0 deletions ext/node/polyfills/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
8 changes: 4 additions & 4 deletions tests/unit_node/sqlite_test.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 4a2b8fc

Please sign in to comment.