diff options
author | stephan <stephan@noemail.net> | 2022-12-10 15:13:29 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-12-10 15:13:29 +0000 |
commit | 9cb6ff27923b340c06d8bae1b8a6130a3e5b8571 (patch) | |
tree | 7b8140dcb313aca80719b87e14818890e7b801ad /ext/wasm/api/sqlite3-api-prologue.js | |
parent | 5c99d91e53cd08058b3e6737945bd9a773289ec4 (diff) | |
download | sqlite-9cb6ff27923b340c06d8bae1b8a6130a3e5b8571.tar.gz sqlite-9cb6ff27923b340c06d8bae1b8a6130a3e5b8571.zip |
Expose sqlite3_column_value() to WASM and add sqlite3_column_js().
FossilOrigin-Name: 7783aa4af1331190fd1f42a71bb724041e2e82b51745f9740926e4ead83a97ed
Diffstat (limited to 'ext/wasm/api/sqlite3-api-prologue.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-prologue.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ext/wasm/api/sqlite3-api-prologue.js b/ext/wasm/api/sqlite3-api-prologue.js index 219581801..ff79206e5 100644 --- a/ext/wasm/api/sqlite3-api-prologue.js +++ b/ext/wasm/api/sqlite3-api-prologue.js @@ -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, |