1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

Enhance oo1.DB.exec() to simplify returning whole result sets.

FossilOrigin-Name: 7b168ee2af09f04b41a6ef4c14ccaddc0c9b0bfe9dc1e6a86d8f5317606bd78d
This commit is contained in:
stephan
2023-01-28 05:09:26 +00:00
parent 65f7942d06
commit e84454ff16
5 changed files with 35 additions and 21 deletions

View File

@ -422,6 +422,10 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
default:
toss3("Invalid returnValue value:",opt.returnValue);
}
if(!opt.callback && !opt.returnValue && undefined!==opt.rowMode){
if(!opt.resultRows) opt.resultRows = [];
out.returnVal = ()=>opt.resultRows;
}
if(opt.callback || opt.resultRows){
switch((undefined===opt.rowMode)
? 'array' : opt.rowMode) {
@ -770,8 +774,11 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
- `returnValue`: is a string specifying what this function
should return:
A) The default value is `"this"`, meaning that the
DB object itself should be returned.
A) The default value is (usually) `"this"`, meaning that the
DB object itself should be returned. The exceptions is if
the caller passes neither of `callback` nor `returnValue`
but does pass an explicit `rowMode` then the default
`returnValue` is `"resultRows"`, described below.
B) `"resultRows"` means to return the value of the
`resultRows` option. If `resultRows` is not set, this
@ -791,9 +798,6 @@ self.sqlite3ApiBootstrap.initializers.push(function(sqlite3){
- `callback` and `resultRows`: permit an array entries with
semantics similar to those described for `bind` above.
- If passed neither a callback nor returnValue but is passed a
rowMode, default to returning the result set.
*/
exec: function(/*(sql [,obj]) || (obj)*/){
affirmDbOpen(this);