Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -2352,20 +2352,6 @@ changes:

Legacy alias for [`--no-require-module`][].

### `--no-experimental-sqlite`

<!-- YAML
added: v22.5.0
changes:
- version:
- v23.4.0
- v22.13.0
pr-url: https://github.com/nodejs/node/pull/55890
description: SQLite is unflagged but still experimental.
-->

Disable the [`node:sqlite`][] module.

### `--no-experimental-vfs`

<!-- YAML
Expand Down Expand Up @@ -4329,6 +4315,7 @@ one is included in the list below.
* `--experimental-require-module`
* `--experimental-shadow-realm`
* `--experimental-specifier-resolution`
* `--experimental-sqlite`
* `--experimental-stream-iter`
* `--experimental-strip-private-modules`
* `--experimental-test-isolation`
Expand Down Expand Up @@ -4364,7 +4351,6 @@ one is included in the list below.
* `--no-deprecation`
* `--no-experimental-ffi`
* `--no-experimental-global-navigator`
* `--no-experimental-sqlite`
* `--no-experimental-strip-types`
* `--no-experimental-vfs`
* `--no-experimental-web-worker`
Expand Down Expand Up @@ -5007,7 +4993,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
[`inspector.open()`]: inspector.md#inspectoropenport-host-wait
[`net.getDefaultAutoSelectFamilyAttemptTimeout()`]: net.md#netgetdefaultautoselectfamilyattempttimeout
[`node:ffi`]: ffi.md
[`node:sqlite`]: sqlite.md
[`node:stream/iter`]: stream_iter.md
[`node:vfs`]: vfs.md
[`permission.drop()`]: permissions.md#permissiondropscope-reference
Expand Down
12 changes: 12 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2548,6 +2548,17 @@ OpenSSL crypto support.
An attempt was made to use features that require [ICU][], but Node.js was not
compiled with ICU support.

<a id="ERR_NO_SQLITE"></a>

### `ERR_NO_SQLITE`

<!-- YAML
added: REPLACEME
-->

An attempt was made to use [`node:sqlite`][], but Node.js was not compiled with
SQLite support.

<a id="ERR_NO_TEMPORAL"></a>

### `ERR_NO_TEMPORAL`
Expand Down Expand Up @@ -4872,6 +4883,7 @@ An error occurred trying to allocate memory. This should never happen.
[`new URL(input)`]: url.md#new-urlinput-base
[`new URLPattern(input)`]: url.md#new-urlpatternstring-baseurl-options
[`new URLSearchParams(iterable)`]: url.md#new-urlsearchparamsiterable
[`node:sqlite`]: sqlite.md
[`package.json`]: packages.md#nodejs-packagejson-field-definitions
[`postMessage()`]: worker_threads.md#portpostmessagevalue-transferlist
[`postMessageToThread()`]: worker_threads.md#worker_threadspostmessagetothreadthreadid-value-transferlist-timeout
Expand Down
7 changes: 7 additions & 0 deletions doc/api/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<!-- YAML
added: v22.5.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/67698
description: No longer disableable with the `--no-experimental-sqlite` CLI flag.
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/67654
description: SQLite is now stable.
Expand Down Expand Up @@ -39,6 +42,9 @@ This module is only available under the `node:` scheme. SQL trace events can
be observed via the [`diagnostics_channel`][] module. See
[`'sqlite.db.query'`][] for details.

When Node.js is built without SQLite support, loading this module throws
[`ERR_NO_SQLITE`][].

The following example shows the basic usage of the `node:sqlite` module to open
an in-memory database, write data to the database, and then read the data back.

Expand Down Expand Up @@ -2154,6 +2160,7 @@ callback function to indicate what type of operation is being authorized.
[`'sqlite.db.query'`]: diagnostics_channel.md#event-sqlitedbquery
[`ATTACH DATABASE`]: https://www.sqlite.org/lang_attach.html
[`ERR_INVALID_STATE`]: errors.md#err_invalid_state
[`ERR_NO_SQLITE`]: errors.md#err_no_sqlite
[`PRAGMA foreign_keys`]: https://www.sqlite.org/pragma.html#pragma_foreign_keys
[`SQLITE_DBCONFIG_DEFENSIVE`]: https://www.sqlite.org/c3ref/c_dbconfig_defensive.html#sqlitedbconfigdefensive
[`SQLITE_DETERMINISTIC`]: https://www.sqlite.org/c3ref/c_deterministic.html
Expand Down
4 changes: 0 additions & 4 deletions doc/node-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,6 @@
"type": "boolean",
"description": ""
},
"experimental-sqlite": {
"type": "boolean",
"description": "experimental node:sqlite module"
},
"experimental-stream-iter": {
"type": "boolean",
"description": "experimental iterable streams API (node:stream/iter)"
Expand Down
7 changes: 2 additions & 5 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -1250,9 +1250,6 @@ Disable exposition of Navigator API on the global scope.
.It Fl -no-experimental-require-module
Legacy alias for \fB--no-require-module\fR.
.
.It Fl -no-experimental-sqlite
Disable the \fBnode:sqlite\fR module.
.
.It Fl -no-experimental-vfs
Disable the experimental \fBnode:vfs\fR module and \fB--vfs-load\fR.
.
Expand Down Expand Up @@ -2301,6 +2298,8 @@ one is included in the list below.
.It
\fB--experimental-specifier-resolution\fR
.It
\fB--experimental-sqlite\fR
.It
\fB--experimental-stream-iter\fR
.It
\fB--experimental-strip-private-modules\fR
Expand Down Expand Up @@ -2371,8 +2370,6 @@ one is included in the list below.
.It
\fB--no-experimental-global-navigator\fR
.It
\fB--no-experimental-sqlite\fR
.It
\fB--no-experimental-strip-types\fR
.It
\fB--no-experimental-vfs\fR
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ const builtinModulePolicies = [
['dtls', true, '--experimental-dtls'],
['ffi', true, '--experimental-ffi'],
['sea', true, null],
['sqlite', true, '--experimental-sqlite'],
['sqlite', true, null],
['quic', true, '--experimental-quic'],
['stream/iter', false, '--experimental-stream-iter'],
['test', true, null],
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,8 @@ E('ERR_NO_CRYPTO',
'Node.js is not compiled with OpenSSL crypto support', Error);
E('ERR_NO_ICU',
'%s is not supported on Node.js compiled without ICU', TypeError);
E('ERR_NO_SQLITE',
'Node.js is not compiled with SQLite support', Error);
E('ERR_NO_TEMPORAL',
'Temporal is not supported in this environment', Error);
E('ERR_NO_TYPESCRIPT',
Expand Down
6 changes: 6 additions & 0 deletions lib/sqlite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
'use strict';

const { ERR_NO_SQLITE } = require('internal/errors').codes;

if (!process.versions.sqlite) {
throw new ERR_NO_SQLITE();
}

const { Database, Statement, Session, constants, backup } =
internalBinding('sqlite');

Expand Down
6 changes: 1 addition & 5 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -796,11 +796,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
true);
AddOption("--experimental-websocket", "", NoOp{}, kAllowedInEnvvar);
AddOption("--experimental-global-customevent", "", NoOp{}, kAllowedInEnvvar);
AddOption("--experimental-sqlite",
"experimental node:sqlite module",
BOOL_FIELD(experimental_sqlite),
kAllowedInEnvvar,
HAVE_SQLITE);
AddOption("--experimental-sqlite", "", NoOp{}, kAllowedInEnvvar);
AddOption("--experimental-stream-iter",
"experimental iterable streams API (node:stream/iter)",
BOOL_FIELD(experimental_stream_iter),
Expand Down
1 change: 0 additions & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ class EnvironmentOptions : public Options {
DEFINE_BOOL_FIELD(experimental_ffi) = HAVE_FFI;
DEFINE_BOOL_FIELD(experimental_web_worker) = true;
DEFINE_BOOL_FIELD(experimental_websocket) = true;
DEFINE_BOOL_FIELD(experimental_sqlite) = HAVE_SQLITE;
DEFINE_BOOL_FIELD(experimental_stream_iter) = EXPERIMENTALS_DEFAULT_VALUE;
DEFINE_BOOL_FIELD(experimental_vfs) = true;
DEFINE_BOOL_FIELD(vfs_load) = false;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-sqlite-session.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Flags: --expose-gc --experimental-sqlite
// Flags: --expose-gc
'use strict';
const { skipIfSQLiteMissing } = require('../common');
skipIfSQLiteMissing();
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-sqlite-without-sqlite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

const { hasSQLite } = require('../common');
const assert = require('node:assert');

if (hasSQLite) {
assert.strictEqual(typeof require('node:sqlite').Database, 'function');
} else {
assert.throws(() => require('node:sqlite'), { code: 'ERR_NO_SQLITE' });
}
31 changes: 20 additions & 11 deletions test/parallel/test-sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,31 @@ suite('accessing the node:sqlite module', () => {
});
});

test('can be disabled with --no-experimental-sqlite flag', async (t) => {
const {
stdout,
stderr,
code,
signal,
} = await spawnPromisified(process.execPath, [
test('can be accessed with the no-op --experimental-sqlite flag', async (t) => {
const result = await spawnPromisified(process.execPath, [
'--experimental-sqlite',
'-p',
'typeof require("node:sqlite").Database',
]);

t.assert.deepStrictEqual(result, {
code: 0,
signal: null,
stderr: '',
stdout: 'function\n',
});
});

test('cannot be disabled with --no-experimental-sqlite', async (t) => {
const { code, signal, stderr } = await spawnPromisified(process.execPath, [
'--no-experimental-sqlite',
'-e',
'require("node:sqlite")',
'',
]);

t.assert.strictEqual(stdout, '');
t.assert.match(stderr, /No such built-in module: node:sqlite/);
t.assert.notStrictEqual(code, 0);
t.assert.strictEqual(code, 9);
t.assert.strictEqual(signal, null);
t.assert.match(stderr, /--no-experimental-sqlite is an invalid negation/);
});
});

Expand Down
Loading