Skip to content

Commit

Permalink
doc,lib,src,test: unflag sqlite module
Browse files Browse the repository at this point in the history
This commit allows the node:sqlite module to be used without
starting Node with a CLI flag. The module is still experimental.

Fixes: #55854
  • Loading branch information
cjihrig committed Nov 17, 2024
1 parent 9f2885a commit de77663
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 25 deletions.
22 changes: 13 additions & 9 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1065,14 +1065,6 @@ added:

Use this flag to enable [ShadowRealm][] support.

### `--experimental-sqlite`

<!-- YAML
added: v22.5.0
-->

Enable the experimental [`node:sqlite`][] module.

### `--experimental-strip-types`

<!-- YAML
Expand Down Expand Up @@ -1693,6 +1685,18 @@ Disable support for loading a synchronous ES module graph in `require()`.

See [Loading ECMAScript modules using `require()`][].

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

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

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

### `--no-experimental-websocket`

<!-- YAML
Expand Down Expand Up @@ -3043,7 +3047,6 @@ one is included in the list below.
* `--experimental-require-module`
* `--experimental-shadow-realm`
* `--experimental-specifier-resolution`
* `--experimental-sqlite`
* `--experimental-strip-types`
* `--experimental-top-level-await`
* `--experimental-transform-types`
Expand Down Expand Up @@ -3080,6 +3083,7 @@ one is included in the list below.
* `--no-deprecation`
* `--no-experimental-global-navigator`
* `--no-experimental-repl-await`
* `--no-experimental-sqlite`
* `--no-experimental-websocket`
* `--no-extra-info-on-fatal-exception`
* `--no-force-async-hooks-checks`
Expand Down
4 changes: 1 addition & 3 deletions doc/api/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
added: v22.5.0
-->

> Stability: 1.1 - Active development. Enable this API with the
> [`--experimental-sqlite`][] CLI flag.
> Stability: 1.1 - Active development.
<!-- source_link=lib/sqlite.js -->

Expand Down Expand Up @@ -318,7 +317,6 @@ exception.
| `BLOB` | {Uint8Array} |

[SQL injection]: https://en.wikipedia.org/wiki/SQL_injection
[`--experimental-sqlite`]: cli.md#--experimental-sqlite
[`PRAGMA foreign_keys`]: https://www.sqlite.org/pragma.html#pragma_foreign_keys
[`sqlite3_changes64()`]: https://www.sqlite.org/c3ref/changes.html
[`sqlite3_close_v2()`]: https://www.sqlite.org/c3ref/close.html
Expand Down
6 changes: 3 additions & 3 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ Enable the experimental permission model.
.It Fl -experimental-shadow-realm
Use this flag to enable ShadowRealm support.
.
.It Fl -experimental-sqlite
Enable the experimental node:sqlite module.
.
.It Fl -experimental-test-coverage
Enable code coverage in the test runner.
.
Expand Down Expand Up @@ -215,6 +212,9 @@ Enable experimental support for the Web Storage API.
.It Fl -no-experimental-repl-await
Disable top-level await keyword support in REPL.
.
.It Fl -no-experimental-sqlite
Disable the experimental node:sqlite module.
.
.It Fl -experimental-vm-modules
Enable experimental ES module support in VM module.
.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/process/pre_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ function setupNavigator() {
}

function setupSQLite() {
if (!getOptionValue('--experimental-sqlite')) {
if (getOptionValue('--no-experimental-sqlite')) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
AddOption("--experimental-sqlite",
"experimental node:sqlite module",
&EnvironmentOptions::experimental_sqlite,
kAllowedInEnvvar);
kAllowedInEnvvar,
true);
AddOption("--experimental-webstorage",
"experimental Web Storage API",
&EnvironmentOptions::experimental_webstorage,
Expand Down
2 changes: 1 addition & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class EnvironmentOptions : public Options {
bool experimental_eventsource = false;
bool experimental_fetch = true;
bool experimental_websocket = true;
bool experimental_sqlite = false;
bool experimental_sqlite = true;
bool experimental_webstorage = false;
std::string localstorage_file;
bool experimental_global_navigator = true;
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-sqlite-data-types.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Flags: --experimental-sqlite
'use strict';
require('../common');
const tmpdir = require('../common/tmpdir');
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-sqlite-database-sync.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Flags: --experimental-sqlite
'use strict';
require('../common');
const tmpdir = require('../common/tmpdir');
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-sqlite-named-parameters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Flags: --experimental-sqlite
'use strict';
require('../common');
const tmpdir = require('../common/tmpdir');
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-sqlite-statement-sync.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Flags: --experimental-sqlite
'use strict';
require('../common');
const tmpdir = require('../common/tmpdir');
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-sqlite-transactions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Flags: --experimental-sqlite
'use strict';
require('../common');
const tmpdir = require('../common/tmpdir');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-sqlite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Flags: --experimental-sqlite
'use strict';
const { spawnPromisified } = require('../common');
const tmpdir = require('../common/tmpdir');
Expand All @@ -23,13 +22,14 @@ suite('accessing the node:sqlite module', () => {
});
});

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

0 comments on commit de77663

Please sign in to comment.