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
PR-URL: #55890
Reviewed-By: Jake Yuesong Li <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
cjihrig authored and aduh95 committed Dec 10, 2024
1 parent 0bd1d3f commit 695f582
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 @@ -1061,14 +1061,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 @@ -1688,6 +1680,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 @@ -3073,7 +3077,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 @@ -3112,6 +3115,7 @@ one is included in the list below.
* `--no-experimental-global-navigator`
* `--no-experimental-global-webcrypto`
* `--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 @@ -432,7 +431,6 @@ The following constants are meant for use with [`database.applyChangeset()`](#da

[Changesets and Patchsets]: https://www.sqlite.org/sessionintro.html#changesets_and_patchsets
[SQL injection]: https://en.wikipedia.org/wiki/SQL_injection
[`--experimental-sqlite`]: cli.md#--experimental-sqlite
[`ATTACH DATABASE`]: https://www.sqlite.org/lang_attach.html
[`PRAGMA foreign_keys`]: https://www.sqlite.org/pragma.html#pragma_foreign_keys
[`sqlite3_changes64()`]: https://www.sqlite.org/c3ref/changes.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 @@ -224,6 +221,9 @@ Disable exposition of the Web Crypto API on the global scope.
.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 @@ -382,7 +382,7 @@ function setupWebCrypto() {
}

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 @@ -430,7 +430,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_customevent = 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 695f582

Please sign in to comment.