Skip to content

Commit 8508790

Browse files
committed
sqlite,doc: make path argument consistent in all interfaces
1 parent 79c1ca1 commit 8508790

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

doc/api/sqlite.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,21 @@ added: v22.5.0
8080
changes:
8181
- version: REPLACEME
8282
pr-url: https://github.com/nodejs/node/pull/56991
83-
description: The `location` argument now supports Buffer and URL objects.
83+
description: The `path` argument now supports Buffer and URL objects.
8484
-->
8585

8686
This class represents a single [connection][] to a SQLite database. All APIs
8787
exposed by this class execute synchronously.
8888

89-
### `new DatabaseSync(location[, options])`
89+
### `new DatabaseSync(path[, options])`
9090

9191
<!-- YAML
9292
added: v22.5.0
9393
-->
9494

95-
* `location` {string | Buffer | URL} The location of the database. A SQLite database can be
95+
* `path` {string | Buffer | URL} The path of the database. A SQLite database can be
9696
stored in a file or completely [in memory][]. To use a file-backed database,
97-
the location should be a file path. To use an in-memory database, the location
97+
the path should be a file path. To use an in-memory database, the path
9898
should be the special name `':memory:'`.
9999
* `options` {Object} Configuration options for the database connection. The
100100
following options are supported:
@@ -204,7 +204,7 @@ wrapper around [`sqlite3_create_function_v2()`][].
204204
added: v22.5.0
205205
-->
206206

207-
Opens the database specified in the `location` argument of the `DatabaseSync`
207+
Opens the database specified in the `path` argument of the `DatabaseSync`
208208
constructor. This method should only be used when the database is not opened via
209209
the constructor. An exception is thrown if the database is already open.
210210

@@ -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)