Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5559456

Browse filesBrowse files
himself65richardlau
authored andcommitted
sqlite: add sqlite-type symbol for DatabaseSync
PR-URL: #59405 Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
1 parent 0a05d06 commit 5559456
Copy full SHA for 5559456

File tree

Expand file treeCollapse file tree

2 files changed

+16
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-0
lines changed
Open diff view settings
Collapse file

‎src/node_sqlite.cc‎

Copy file name to clipboardExpand all lines: src/node_sqlite.cc
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,6 +2740,13 @@ static void Initialize(Local<Object> target,
27402740
db_tmpl,
27412741
FIXED_ONE_BYTE_STRING(isolate, "isTransaction"),
27422742
DatabaseSync::IsTransactionGetter);
2743+
Local<String> sqlite_type_key = FIXED_ONE_BYTE_STRING(isolate, "sqlite-type");
2744+
Local<v8::Symbol> sqlite_type_symbol =
2745+
v8::Symbol::For(isolate, sqlite_type_key);
2746+
Local<String> database_sync_string =
2747+
FIXED_ONE_BYTE_STRING(isolate, "node:sqlite");
2748+
db_tmpl->InstanceTemplate()->Set(sqlite_type_symbol, database_sync_string);
2749+
27432750
SetConstructorFunction(context, target, "DatabaseSync", db_tmpl);
27442751
SetConstructorFunction(context,
27452752
target,
Collapse file

‎test/parallel/test-sqlite-database-sync.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-sqlite-database-sync.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,15 @@ suite('DatabaseSync() constructor', () => {
281281
{ changes: 1, lastInsertRowid: 1 },
282282
);
283283
});
284+
285+
test('has sqlite-type symbol property', (t) => {
286+
const dbPath = nextDb();
287+
const db = new DatabaseSync(dbPath);
288+
t.after(() => { db.close(); });
289+
290+
const sqliteTypeSymbol = Symbol.for('sqlite-type');
291+
t.assert.strictEqual(db[sqliteTypeSymbol], 'node:sqlite');
292+
});
284293
});
285294

286295
suite('DatabaseSync.prototype.open()', () => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.