From 338d70b752fd918ebd568f432373065e04539830 Mon Sep 17 00:00:00 2001 From: Colin Ihrig Date: Sun, 5 Jan 2025 00:35:54 -0500 Subject: [PATCH] sqlite: enable SQL math functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit enables SQLite math functions. Fixes: https://github.com/nodejs/node/issues/56435 PR-URL: https://github.com/nodejs/node/pull/56447 Reviewed-By: Michaƫl Zasso Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- deps/sqlite/sqlite.gyp | 1 + deps/sqlite/unofficial.gni | 1 + test/parallel/test-sqlite.js | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/deps/sqlite/sqlite.gyp b/deps/sqlite/sqlite.gyp index c3ecef214ad..7a556018ca0 100644 --- a/deps/sqlite/sqlite.gyp +++ b/deps/sqlite/sqlite.gyp @@ -13,6 +13,7 @@ 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden }, 'defines': [ + 'SQLITE_ENABLE_MATH_FUNCTIONS', 'SQLITE_ENABLE_SESSION', 'SQLITE_ENABLE_PREUPDATE_HOOK' ], diff --git a/deps/sqlite/unofficial.gni b/deps/sqlite/unofficial.gni index b26e1335eac..a4fb26e7056 100644 --- a/deps/sqlite/unofficial.gni +++ b/deps/sqlite/unofficial.gni @@ -8,6 +8,7 @@ template("sqlite_gn_build") { config("sqlite_config") { include_dirs = [ "." ] defines = [ + "SQLITE_ENABLE_MATH_FUNCTIONS", "SQLITE_ENABLE_SESSION", "SQLITE_ENABLE_PREUPDATE_HOOK", ] diff --git a/test/parallel/test-sqlite.js b/test/parallel/test-sqlite.js index 87162526ffa..c9a45fa22ae 100644 --- a/test/parallel/test-sqlite.js +++ b/test/parallel/test-sqlite.js @@ -103,3 +103,11 @@ test('PRAGMAs are supported', (t) => { { __proto__: null, journal_mode: 'wal' }, ); }); + +test('math functions are enabled', (t) => { + const db = new DatabaseSync(':memory:'); + t.assert.deepStrictEqual( + db.prepare('SELECT PI() AS pi').get(), + { __proto__: null, pi: 3.141592653589793 }, + ); +});