sqlite: enable SQL math functions

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 <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
pull/45096/merge
Colin Ihrig 2025-01-05 00:35:54 -05:00 committed by GitHub
parent d0ff34f4b6
commit 338d70b752
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 0 deletions

View File

@ -13,6 +13,7 @@
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
},
'defines': [
'SQLITE_ENABLE_MATH_FUNCTIONS',
'SQLITE_ENABLE_SESSION',
'SQLITE_ENABLE_PREUPDATE_HOOK'
],

View File

@ -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",
]

View File

@ -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 },
);
});