Skip to content

Commit 6d48eee

Browse files
committed
sqlite,doc: change backup arg name from destination to path
1 parent 79c1ca1 commit 6d48eee

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

doc/api/sqlite.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -538,18 +538,18 @@ exception.
538538
| `TEXT` | {string} |
539539
| `BLOB` | {TypedArray} or {DataView} |
540540

541-
## `sqlite.backup(sourceDb, destination[, options])`
541+
## `sqlite.backup(sourceDb, path[, options])`
542542

543543
<!-- YAML
544544
added: v23.8.0
545545
changes:
546546
- version: REPLACEME
547547
pr-url: https://github.com/nodejs/node/pull/56991
548-
description: The `destination` argument now supports Buffer and URL objects.
548+
description: The `path` argument now supports Buffer and URL objects.
549549
-->
550550

551551
* `sourceDb` {DatabaseSync} The database to backup. The source database must be open.
552-
* `destination` {string | Buffer | URL} The path where the backup will be created. If the file already exists,
552+
* `path` {string | Buffer | URL} The path where the backup will be created. If the file already exists,
553553
the contents will be overwritten.
554554
* `options` {Object} Optional configuration for the backup. The
555555
following properties are supported:

src/node_sqlite.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ void Backup(const FunctionCallbackInfo<Value>& args) {
10481048
ASSIGN_OR_RETURN_UNWRAP(&db, args[0].As<Object>());
10491049
THROW_AND_RETURN_ON_BAD_STATE(env, !db->IsOpen(), "database is not open");
10501050
std::optional<std::string> dest_path =
1051-
ValidateDatabasePath(env, args[1], "destination");
1051+
ValidateDatabasePath(env, args[1], "path");
10521052
if (!dest_path.has_value()) {
10531053
return;
10541054
}

test/parallel/test-sqlite-backup.mjs

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,32 @@ describe('backup()', () => {
5050
backup(database);
5151
}, {
5252
code: 'ERR_INVALID_ARG_TYPE',
53-
message: 'The "destination" argument must be a string, Uint8Array, or URL without null bytes.'
53+
message: 'The "path" argument must be a string, Uint8Array, or URL without null bytes.'
5454
});
5555

5656
t.assert.throws(() => {
5757
backup(database, {});
5858
}, {
5959
code: 'ERR_INVALID_ARG_TYPE',
60-
message: 'The "destination" argument must be a string, Uint8Array, or URL without null bytes.'
60+
message: 'The "path" argument must be a string, Uint8Array, or URL without null bytes.'
6161
});
6262
});
6363

64-
test('throws if the database destination contains null bytes', (t) => {
64+
test('throws if the database path contains null bytes', (t) => {
6565
const database = makeSourceDb();
6666

6767
t.assert.throws(() => {
6868
backup(database, Buffer.from('l\0cation'));
6969
}, {
7070
code: 'ERR_INVALID_ARG_TYPE',
71-
message: 'The "destination" argument must be a string, Uint8Array, or URL without null bytes.'
71+
message: 'The "path" argument must be a string, Uint8Array, or URL without null bytes.'
7272
});
7373

7474
t.assert.throws(() => {
7575
backup(database, 'l\0cation');
7676
}, {
7777
code: 'ERR_INVALID_ARG_TYPE',
78-
message: 'The "destination" argument must be a string, Uint8Array, or URL without null bytes.'
78+
message: 'The "path" argument must be a string, Uint8Array, or URL without null bytes.'
7979
});
8080
});
8181

@@ -297,7 +297,7 @@ test('backup fails when source db is invalid', async (t) => {
297297
});
298298
});
299299

300-
test('backup fails when destination cannot be opened', async (t) => {
300+
test('backup fails when path cannot be opened', async (t) => {
301301
const database = makeSourceDb();
302302

303303
await t.assert.rejects(async () => {

test/parallel/test-sqlite.js

-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ test('URL is supported as the database path', (t) => {
143143
);
144144
});
145145

146-
147146
test('URL query params are supported', (t) => {
148147
const url = pathToFileURL(nextDb());
149148
const db = new DatabaseSync(url);

0 commit comments

Comments
 (0)