Skip to content

Commit db8a03e

Browse files
committed
[bun:sqlite] Add sqlite-type symbol for Database
1 parent a758621 commit db8a03e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/js/bun/sqlite.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ class Statement {
339339
}
340340

341341
const cachedCount = Symbol.for("Bun.Database.cache.count");
342+
const sqliteTypeSymbol = Symbol.for("sqlite-type");
342343

343344
class Database implements SqliteTypes.Database {
344345
constructor(
@@ -437,6 +438,10 @@ class Database implements SqliteTypes.Database {
437438
return SQL.isInTransaction(this.#handle);
438439
}
439440

441+
get [sqliteTypeSymbol]() {
442+
return "bun:sqlite";
443+
}
444+
440445
static open(filename, options) {
441446
return new Database(filename, options);
442447
}

test/js/bun/sqlite/sqlite.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ import path from "path";
88

99
const tmpbase = tmpdir() + path.sep;
1010

11+
describe("sqlite-type symbol", () => {
12+
it("should have the sqlite-type symbol with value 'bun:sqlite'", () => {
13+
const db = new Database(":memory:");
14+
const sqliteTypeSymbol = Symbol.for("sqlite-type");
15+
16+
expect(sqliteTypeSymbol in db).toBe(true);
17+
expect(db[sqliteTypeSymbol]).toBe("bun:sqlite");
18+
19+
db.close();
20+
});
21+
});
22+
1123
describe("as", () => {
1224
it("should return an implementation of the class", () => {
1325
const db = new Database(":memory:");

0 commit comments

Comments
 (0)