aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-worker1.c-pp.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/wasm/api/sqlite3-api-worker1.c-pp.js')
-rw-r--r--ext/wasm/api/sqlite3-api-worker1.c-pp.js25
1 files changed, 20 insertions, 5 deletions
diff --git a/ext/wasm/api/sqlite3-api-worker1.c-pp.js b/ext/wasm/api/sqlite3-api-worker1.c-pp.js
index 991862545..5e088f438 100644
--- a/ext/wasm/api/sqlite3-api-worker1.c-pp.js
+++ b/ext/wasm/api/sqlite3-api-worker1.c-pp.js
@@ -279,11 +279,11 @@
The arguments are in the same form accepted by oo1.DB.exec(), with
the exceptions noted below.
- If the `countChanges` arguments property (added in version 3.43) is
- truthy then the `result` property contained by the returned object
- will have a `changeCount` property which holds the number of changes
- made by the provided SQL. Because the SQL may contain an arbitrary
- number of statements, the `changeCount` is calculated by calling
+ If `args.countChanges` (added in version 3.43) is truthy then the
+ `result` property contained by the returned object will have a
+ `changeCount` property which holds the number of changes made by the
+ provided SQL. Because the SQL may contain an arbitrary number of
+ statements, the `changeCount` is calculated by calling
`sqlite3_total_changes()` before and after the SQL is evaluated. If
the value of `countChanges` is 64 then the `changeCount` property
will be returned as a 64-bit integer in the form of a BigInt (noting
@@ -292,6 +292,15 @@
calling `sqlite3_total_changes64()` before and after the SQL is
evaluated.
+ If the `args.lastInsertRowId` (added in version 3.50.0) is truthy
+ then the `result` property contained by the returned object will
+ have a `lastInsertRowId` will hold a BigInt-type value corresponding
+ to the result of sqlite3_last_insert_rowid(). This value is only
+ fetched once, after the SQL is run, regardless of how many
+ statements the SQL contains. This API has no idea whether the SQL
+ contains any INSERTs, so it is up to the client to apply/rely on
+ this property only when it makes sense to do so.
+
A function-type args.callback property cannot cross
the window/Worker boundary, so is not useful here. If
args.callback is a string then it is assumed to be a
@@ -542,6 +551,12 @@ sqlite3.initWorker1API = function(){
if(undefined !== changeCount){
rc.changeCount = db.changes(true,64===rc.countChanges) - changeCount;
}
+ const lastInsertRowId = !!rc.lastInsertRowId
+ ? sqlite3.capi.sqlite3_last_insert_rowid(db)
+ : undefined;
+ if( undefined!==lastInsertRowId ){
+ rc.lastInsertRowId = lastInsertRowId;
+ }
if(rc.callback instanceof Function){
rc.callback = theCallback;
/* Post a sentinel message to tell the client that the end