GeezerVison is showing github.com — sqlite: add sqlite-type symbol for DatabaseSync · nodejs/node@e7084df
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_sqlite.cc +7Lines changed: 7 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2741,6 +2741,13 @@ static void Initialize(Local<Object> target, |
2741 | 2741 | db_tmpl, |
2742 | 2742 | FIXED_ONE_BYTE_STRING(isolate, "isTransaction"), |
2743 | 2743 | DatabaseSync::IsTransactionGetter); |
| 2744 | + Local<String> sqlite_type_key = FIXED_ONE_BYTE_STRING(isolate, "sqlite-type"); |
| 2745 | + Local<v8::Symbol> sqlite_type_symbol = |
| 2746 | + v8::Symbol::For(isolate, sqlite_type_key); |
| 2747 | + Local<String> database_sync_string = |
| 2748 | + FIXED_ONE_BYTE_STRING(isolate, "node:sqlite"); |
| 2749 | + db_tmpl->InstanceTemplate()->Set(sqlite_type_symbol, database_sync_string); |
| 2750 | + |
2744 | 2751 | SetConstructorFunction(context, target, "DatabaseSync", db_tmpl); |
2745 | 2752 | SetConstructorFunction(context, |
2746 | 2753 | target, |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-sqlite-database-sync.js +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -281,6 +281,15 @@ suite('DatabaseSync() constructor', () => { |
281 | 281 | { changes: 1, lastInsertRowid: 1 }, |
282 | 282 | ); |
283 | 283 | }); |
| 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 | + }); |
284 | 293 | }); |
285 | 294 |
|
286 | 295 | suite('DatabaseSync.prototype.open()', () => { |
|