Skip to content

Commit 313d9db

Browse files
Renegade334aduh95
authored andcommitted
doc: clarify sqlite user-defined function behaviour
PR-URL: #56786 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ulises Gascón <[email protected]>
1 parent f16acc8 commit 313d9db

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

doc/api/sqlite.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,14 @@ added: v22.13.0
180180
* `useBigIntArguments` {boolean} If `true`, integer arguments to `function`
181181
are converted to `BigInt`s. If `false`, integer arguments are passed as
182182
JavaScript numbers. **Default:** `false`.
183-
* `varargs` {boolean} If `true`, `function` can accept a variable number of
184-
arguments. If `false`, `function` must be invoked with exactly
185-
`function.length` arguments. **Default:** `false`.
183+
* `varargs` {boolean} If `true`, `function` may be invoked with any number of
184+
arguments (between zero and [`SQLITE_MAX_FUNCTION_ARG`][]). If `false`,
185+
`function` must be invoked with exactly `function.length` arguments.
186+
**Default:** `false`.
186187
* `function` {Function} The JavaScript function to call when the SQLite
187-
function is invoked.
188+
function is invoked. The return value of this function should be a valid
189+
SQLite data type: see [Type conversion between JavaScript and SQLite][].
190+
The result defaults to `NULL` if the return value is `undefined`.
188191

189192
This method is used to create SQLite user-defined functions. This method is a
190193
wrapper around [`sqlite3_create_function_v2()`][].
@@ -583,10 +586,12 @@ resolution handler passed to [`database.applyChangeset()`][]. See also
583586
[Constants Passed To The Conflict Handler]: https://www.sqlite.org/session/c_changeset_conflict.html
584587
[Constants Returned From The Conflict Handler]: https://www.sqlite.org/session/c_changeset_abort.html
585588
[SQL injection]: https://en.wikipedia.org/wiki/SQL_injection
589+
[Type conversion between JavaScript and SQLite]: #type-conversion-between-javascript-and-sqlite
586590
[`ATTACH DATABASE`]: https://www.sqlite.org/lang_attach.html
587591
[`PRAGMA foreign_keys`]: https://www.sqlite.org/pragma.html#pragma_foreign_keys
588592
[`SQLITE_DETERMINISTIC`]: https://www.sqlite.org/c3ref/c_deterministic.html
589593
[`SQLITE_DIRECTONLY`]: https://www.sqlite.org/c3ref/c_deterministic.html
594+
[`SQLITE_MAX_FUNCTION_ARG`]: https://www.sqlite.org/limits.html#max_function_arg
590595
[`database.applyChangeset()`]: #databaseapplychangesetchangeset-options
591596
[`sqlite3_changes64()`]: https://www.sqlite.org/c3ref/changes.html
592597
[`sqlite3_close_v2()`]: https://www.sqlite.org/c3ref/close.html

0 commit comments

Comments
 (0)