From 1d01ad67737ce8b88a67850e45340377413b0c11 Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Mon, 18 Nov 2024 22:23:18 -0500 Subject: [PATCH] doc,lib,src,test: unflag sqlite module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit allows the node:sqlite module to be used without starting Node with a CLI flag. The module is still experimental. Fixes: https://github.com/nodejs/node/issues/55854 PR-URL: https://github.com/nodejs/node/pull/55890 Reviewed-By: Jake Yuesong Li Reviewed-By: Marco Ippolito Reviewed-By: Moshe Atlow Reviewed-By: Michaƫl Zasso Reviewed-By: Matteo Collina --- doc/api/cli.md | 22 +++++++++++-------- doc/api/sqlite.md | 4 +--- doc/node.1 | 6 ++--- lib/internal/process/pre_execution.js | 2 +- src/node_options.cc | 3 ++- src/node_options.h | 2 +- test/parallel/test-sqlite-data-types.js | 1 - test/parallel/test-sqlite-database-sync.js | 1 - test/parallel/test-sqlite-named-parameters.js | 1 - test/parallel/test-sqlite-statement-sync.js | 1 - test/parallel/test-sqlite-transactions.js | 1 - test/parallel/test-sqlite.js | 4 ++-- 12 files changed, 23 insertions(+), 25 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 52df262ec8c..d232c342302 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1065,14 +1065,6 @@ added: Use this flag to enable [ShadowRealm][] support. -### `--experimental-sqlite` - - - -Enable the experimental [`node:sqlite`][] module. - ### `--experimental-strip-types` + +Disable the experimental [`node:sqlite`][] module. + ### `--no-experimental-websocket` -> Stability: 1.1 - Active development. Enable this API with the -> [`--experimental-sqlite`][] CLI flag. +> Stability: 1.1 - Active development. @@ -412,7 +411,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 diff --git a/doc/node.1 b/doc/node.1 index 3d92fcd7858..02628f8e238 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -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. . @@ -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. . diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js index 08945a62d42..41ebf85900b 100644 --- a/lib/internal/process/pre_execution.js +++ b/lib/internal/process/pre_execution.js @@ -303,7 +303,7 @@ function setupNavigator() { } function setupSQLite() { - if (!getOptionValue('--experimental-sqlite')) { + if (getOptionValue('--no-experimental-sqlite')) { return; } diff --git a/src/node_options.cc b/src/node_options.cc index 4b36a516c80..5ef5a7b6cf9 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -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, diff --git a/src/node_options.h b/src/node_options.h index a3521e9aea8..aa7a2ce3eba 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -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; diff --git a/test/parallel/test-sqlite-data-types.js b/test/parallel/test-sqlite-data-types.js index df77a90908e..75f1257f4d0 100644 --- a/test/parallel/test-sqlite-data-types.js +++ b/test/parallel/test-sqlite-data-types.js @@ -1,4 +1,3 @@ -// Flags: --experimental-sqlite 'use strict'; require('../common'); const tmpdir = require('../common/tmpdir'); diff --git a/test/parallel/test-sqlite-database-sync.js b/test/parallel/test-sqlite-database-sync.js index 0bf5b2c139c..b9ce0b8ad2a 100644 --- a/test/parallel/test-sqlite-database-sync.js +++ b/test/parallel/test-sqlite-database-sync.js @@ -1,4 +1,3 @@ -// Flags: --experimental-sqlite 'use strict'; require('../common'); const tmpdir = require('../common/tmpdir'); diff --git a/test/parallel/test-sqlite-named-parameters.js b/test/parallel/test-sqlite-named-parameters.js index 3060e252235..d8091a0fd14 100644 --- a/test/parallel/test-sqlite-named-parameters.js +++ b/test/parallel/test-sqlite-named-parameters.js @@ -1,4 +1,3 @@ -// Flags: --experimental-sqlite 'use strict'; require('../common'); const tmpdir = require('../common/tmpdir'); diff --git a/test/parallel/test-sqlite-statement-sync.js b/test/parallel/test-sqlite-statement-sync.js index 8cd3b64ab4b..1c288401368 100644 --- a/test/parallel/test-sqlite-statement-sync.js +++ b/test/parallel/test-sqlite-statement-sync.js @@ -1,4 +1,3 @@ -// Flags: --experimental-sqlite 'use strict'; require('../common'); const tmpdir = require('../common/tmpdir'); diff --git a/test/parallel/test-sqlite-transactions.js b/test/parallel/test-sqlite-transactions.js index b5ed187e067..304d27d3f3c 100644 --- a/test/parallel/test-sqlite-transactions.js +++ b/test/parallel/test-sqlite-transactions.js @@ -1,4 +1,3 @@ -// Flags: --experimental-sqlite 'use strict'; require('../common'); const tmpdir = require('../common/tmpdir'); diff --git a/test/parallel/test-sqlite.js b/test/parallel/test-sqlite.js index f8b122131fe..825e44fb296 100644 --- a/test/parallel/test-sqlite.js +++ b/test/parallel/test-sqlite.js @@ -1,4 +1,3 @@ -// Flags: --experimental-sqlite 'use strict'; const { spawnPromisified } = require('../common'); const tmpdir = require('../common/tmpdir'); @@ -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")', ]);