aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/sqlite-cross-process.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-22 19:09:52 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-22 19:09:52 -0800
commit349224869751c9d74540d5de75bf0681c69dd45d (patch)
tree7dc7f48a085a217f187b80a445b351a7e4f332eb /test/bun.js/sqlite-cross-process.js
parentbc7192dca1c9da8714f72be3848100e9d16a5425 (diff)
downloadbun-349224869751c9d74540d5de75bf0681c69dd45d.tar.gz
bun-349224869751c9d74540d5de75bf0681c69dd45d.tar.zst
bun-349224869751c9d74540d5de75bf0681c69dd45d.zip
Fixes #1366
Diffstat (limited to 'test/bun.js/sqlite-cross-process.js')
-rw-r--r--test/bun.js/sqlite-cross-process.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/bun.js/sqlite-cross-process.js b/test/bun.js/sqlite-cross-process.js
new file mode 100644
index 000000000..d5b9b87b5
--- /dev/null
+++ b/test/bun.js/sqlite-cross-process.js
@@ -0,0 +1,45 @@
+// https://github.com/oven-sh/bun/issues/1366
+import { Database } from "bun:sqlite";
+import { rmSync } from "fs";
+
+const dir = process.env.SQLITE_DIR;
+
+rmSync(dir + "get-persist.sqlite", { force: true });
+
+var db = Database.open(dir + "get-persist.sqlite", { create: true });
+
+// Note, I've played with various values and it doesn't seem to change
+// the behavior. The "beter-sqlite3" npm package does not exhibit this
+// bug, so it doesn't seem to be a general SQLite thing.
+db.run(`PRAGMA journal_mode = WAL`);
+db.run(`PRAGMA synchrounous = NORMAL`);
+
+db.run(
+ `CREATE TABLE IF NOT EXISTS examples (
+ id TEXT PRIMARY KEY
+ )`,
+);
+
+// This persists, but if you place this call
+db.run(
+ `
+ INSERT INTO examples
+ VALUES ('hello')
+ ON CONFLICT (id) DO
+ UPDATE SET id='hello'
+ RETURNING id
+ `,
+);
+
+db.query(`SELECT id FROM examples WHERE id='hello'`).get().id;
+db.query(
+ `
+INSERT INTO examples
+VALUES ('world')
+ON CONFLICT (id) DO
+ UPDATE SET id='world'
+RETURNING id
+`,
+).get();
+
+process.exit(0);