From 695f582f3cfc55ef390b44c85fc29a9994b703bd 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 703ea509597594..c068a3acf1ef03 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1061,14 +1061,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. @@ -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 diff --git a/doc/node.1 b/doc/node.1 index 46829cc3b2b0de..16d5337a7e370a 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. . @@ -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. . diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js index f46a621e524207..d77dd84f89225f 100644 --- a/lib/internal/process/pre_execution.js +++ b/lib/internal/process/pre_execution.js @@ -382,7 +382,7 @@ function setupWebCrypto() { } 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 3943f9ed7b1731..a078518325ed58 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -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, diff --git a/src/node_options.h b/src/node_options.h index 3c146e57829e83..80364fa0ba09b4 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_customevent = true; diff --git a/test/parallel/test-sqlite-data-types.js b/test/parallel/test-sqlite-data-types.js index df77a90908eed5..75f1257f4d04b4 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 0bf5b2c139ca03..b9ce0b8ad2aefc 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 3060e252235401..d8091a0fd14b13 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 8cd3b64ab4bc66..1c2884013680df 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 b5ed187e067e6d..304d27d3f3c65f 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 f8b122131fe7a2..825e44fb2965f7 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")', ]);