Skip to content

Commit 1774612

Browse files
LiviaMedeirostargos
authored andcommitted
sqlite: set name and length on sqlite.backup()
PR-URL: #58251 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Edy Silva <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent fcead7c commit 1774612

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/node_sqlite.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2686,9 +2686,11 @@ static void Initialize(Local<Object> target,
26862686

26872687
Local<Function> backup_function;
26882688

2689-
if (!Function::New(context, Backup).ToLocal(&backup_function)) {
2689+
if (!Function::New(context, Backup, Local<Value>(), 2)
2690+
.ToLocal(&backup_function)) {
26902691
return;
26912692
}
2693+
backup_function->SetName(env->backup_string());
26922694

26932695
target->Set(context, env->backup_string(), backup_function).Check();
26942696
}

test/parallel/test-sqlite-backup.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,8 @@ test('backup fails when path cannot be opened', async (t) => {
307307
message: 'unable to open database file'
308308
});
309309
});
310+
311+
test('backup has correct name and length', (t) => {
312+
t.assert.strictEqual(backup.name, 'backup');
313+
t.assert.strictEqual(backup.length, 2);
314+
});

0 commit comments

Comments
 (0)