Skip to content

Commit 91638ee

Browse files
Renegade334targos
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 0f553e5 commit 91638ee

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

doc/api/sqlite.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,14 @@ added: v23.5.0
176176
* `useBigIntArguments` {boolean} If `true`, integer arguments to `function`
177177
are converted to `BigInt`s. If `false`, integer arguments are passed as
178178
JavaScript numbers. **Default:** `false`.
179-
* `varargs` {boolean} If `true`, `function` can accept a variable number of
180-
arguments. If `false`, `function` must be invoked with exactly
181-
`function.length` arguments. **Default:** `false`.
179+
* `varargs` {boolean} If `true`, `function` may be invoked with any number of
180+
arguments (between zero and [`SQLITE_MAX_FUNCTION_ARG`][]). If `false`,
181+
`function` must be invoked with exactly `function.length` arguments.
182+
**Default:** `false`.
182183
* `function` {Function} The JavaScript function to call when the SQLite
183-
function is invoked.
184+
function is invoked. The return value of this function should be a valid
185+
SQLite data type: see [Type conversion between JavaScript and SQLite][].
186+
The result defaults to `NULL` if the return value is `undefined`.
184187

185188
This method is used to create SQLite user-defined functions. This method is a
186189
wrapper around [`sqlite3_create_function_v2()`][].
@@ -579,10 +582,12 @@ resolution handler passed to [`database.applyChangeset()`][]. See also
579582
[Constants Passed To The Conflict Handler]: https://www.sqlite.org/session/c_changeset_conflict.html
580583
[Constants Returned From The Conflict Handler]: https://www.sqlite.org/session/c_changeset_abort.html
581584
[SQL injection]: https://en.wikipedia.org/wiki/SQL_injection
585+
[Type conversion between JavaScript and SQLite]: #type-conversion-between-javascript-and-sqlite
582586
[`ATTACH DATABASE`]: https://www.sqlite.org/lang_attach.html
583587
[`PRAGMA foreign_keys`]: https://www.sqlite.org/pragma.html#pragma_foreign_keys
584588
[`SQLITE_DETERMINISTIC`]: https://www.sqlite.org/c3ref/c_deterministic.html
585589
[`SQLITE_DIRECTONLY`]: https://www.sqlite.org/c3ref/c_deterministic.html
590+
[`SQLITE_MAX_FUNCTION_ARG`]: https://www.sqlite.org/limits.html#max_function_arg
586591
[`database.applyChangeset()`]: #databaseapplychangesetchangeset-options
587592
[`sqlite3_changes64()`]: https://www.sqlite.org/c3ref/changes.html
588593
[`sqlite3_close_v2()`]: https://www.sqlite.org/c3ref/close.html

0 commit comments

Comments
 (0)