aboutsummaryrefslogtreecommitdiff
path: root/ext/wasm/api/sqlite3-api-oo1.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/wasm/api/sqlite3-api-oo1.js')
-rw-r--r--ext/wasm/api/sqlite3-api-oo1.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/ext/wasm/api/sqlite3-api-oo1.js b/ext/wasm/api/sqlite3-api-oo1.js
index d4191cf3f..adfcca4d9 100644
--- a/ext/wasm/api/sqlite3-api-oo1.js
+++ b/ext/wasm/api/sqlite3-api-oo1.js
@@ -440,9 +440,12 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
out.cbArg = (stmt)=>stmt.get(opt.rowMode);
break;
}else if('string'===typeof opt.rowMode && opt.rowMode.length>1){
- /* "$X", ":X", and "@X" fetch column named "X" (case-sensitive!) */
- const prefix = opt.rowMode[0];
- if(':'===prefix || '@'===prefix || '$'===prefix){
+ /* "$X": fetch column named "X" (case-sensitive!). Prior
+ to 2022-12-14 ":X" and "@X" were also permitted, but
+ that seems unnecessary and likely to cause
+ confusion. $ is the clear usability winner because it
+ doesn't require quoting in JS. */
+ if('$'===opt.rowMode[0]){
out.cbArg = function(stmt){
const rc = stmt.get(this.obj)[this.colName];
return (undefined===rc) ? toss3("exec(): unknown result column:",this.colName) : rc;
@@ -740,17 +743,15 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
row. Only that one single value will be passed on.
C) A string with a minimum length of 2 and leading character of
- ':', '$', or '@' will fetch the row as an object, extract that
- one field, and pass that field's value to the callback. Note
- that these keys are case-sensitive so must match the case used
- in the SQL. e.g. `"select a A from t"` with a `rowMode` of
- `'$A'` would work but `'$a'` would not. A reference to a column
- not in the result set will trigger an exception on the first
- row (as the check is not performed until rows are fetched).
- Note also that `$` is a legal identifier character in JS so
- need not be quoted. (Design note: those 3 characters were
- chosen because they are the characters support for naming bound
- parameters.)
+ '$' will fetch the row as an object, extract that one field,
+ and pass that field's value to the callback. Note that these
+ keys are case-sensitive so must match the case used in the
+ SQL. e.g. `"select a A from t"` with a `rowMode` of `'$A'`
+ would work but `'$a'` would not. A reference to a column not in
+ the result set will trigger an exception on the first row (as
+ the check is not performed until rows are fetched). Note also
+ that `$` is a legal identifier character in JS so need not be
+ quoted.
Any other `rowMode` value triggers an exception.
@@ -801,6 +802,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
let bind = opt.bind;
let evalFirstResult = !!(arg.cbArg || opt.columnNames) /* true to evaluate the first result-returning query */;
const stack = wasm.scopedAllocPush();
+ const saveSql = Array.isArray(opt.saveSql) ? opt.saveSql : undefined;
try{
const isTA = util.isSQLableTypedArray(arg.sql)
/* Optimization: if the SQL is a TypedArray we can save some string
@@ -834,9 +836,7 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
pSql = wasm.peekPtr(pzTail);
sqlByteLen = pSqlEnd - pSql;
if(!pStmt) continue;
- if(Array.isArray(opt.saveSql)){
- opt.saveSql.push(capi.sqlite3_sql(pStmt).trim());
- }
+ if(saveSql) saveSql.push(capi.sqlite3_sql(pStmt).trim());
stmt = new Stmt(this, pStmt, BindTypes);
if(bind && stmt.parameterCount){
stmt.bind(bind);