mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Expose sqlite3_column_value() to WASM and add sqlite3_column_js().
FossilOrigin-Name: 7783aa4af1331190fd1f42a71bb724041e2e82b51745f9740926e4ead83a97ed
This commit is contained in:
@ -930,6 +930,7 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
|
||||
["sqlite3_column_name","string", "sqlite3_stmt*", "int"],
|
||||
["sqlite3_column_text","string", "sqlite3_stmt*", "int"],
|
||||
["sqlite3_column_type","int", "sqlite3_stmt*", "int"],
|
||||
["sqlite3_column_value","sqlite3_value*", "sqlite3_stmt*", "int"],
|
||||
["sqlite3_compileoption_get", "string", "int"],
|
||||
["sqlite3_compileoption_used", "int", "string"],
|
||||
["sqlite3_complete", "int", "string:flexible"],
|
||||
@ -1860,6 +1861,25 @@ self.sqlite3ApiBootstrap = function sqlite3ApiBootstrap(
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the result sqlite3_column_value(pStmt,iCol) passed to
|
||||
sqlite3_value_to_js(). The 3rd argument of this function is
|
||||
ignored by this function except to pass it on as the second
|
||||
argument of sqlite3_value_to_js(). If the sqlite3_column_value()
|
||||
returns NULL (e.g. because the column index is out of range),
|
||||
this function returns `undefined`, regardless of the 3rd
|
||||
argument. 3rd argument is falsy and conversion fails, `undefined`
|
||||
will be returned.
|
||||
|
||||
Note that sqlite3_column_value() returns an "unprotected" value
|
||||
object, but in a single-threaded environment (like this one)
|
||||
there is no distinction between protected and unprotected values.
|
||||
*/
|
||||
capi.sqlite3_column_js = function(pStmt, iCol, throwIfCannotConvert=true){
|
||||
const v = capi.sqlite3_column_value(pStmt, iCol);
|
||||
return (0===v) ? undefined : capi.sqlite3_value_to_js(v, throwIfCannotConvert);
|
||||
};
|
||||
|
||||
/* The remainder of the API will be set up in later steps. */
|
||||
const sqlite3 = {
|
||||
WasmAllocError: WasmAllocError,
|
||||
|
Reference in New Issue
Block a user