1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17: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

@@ -1412,14 +1412,26 @@ self.sqlite3InitModule = sqlite3InitModule;
db.selectValue("SELECT "+Number.MIN_SAFE_INTEGER)).
assert(Number.MAX_SAFE_INTEGER ===
db.selectValue("SELECT "+Number.MAX_SAFE_INTEGER));
counter = 0;
db.exec({
let rv = db.exec({
sql: "SELECT a FROM t",
callback: ()=>(1===++counter),
});
T.assert(2===counter,
T.assert(db === rv)
.assert(2===counter,
"Expecting exec step() loop to stop if callback returns false.");
/** If exec() is passed neither callback nor returnValue but
is passed an explicit rowMode then the default returnValue
is the whole result set, as if an empty resultRows option
had been passed. */
rv = db.exec({
sql: "SELECT -1 UNION ALL SELECT -2 UNION ALL SELECT -3 ORDER BY 1 DESC",
rowMode: 0
});
T.assert(Array.isArray(rv)).assert(3===rv.length)
.assert(-1===rv[0]).assert(-3===rv[2]);
rv = db.exec("SELECT 1 WHERE 0",{rowMode: 0});
T.assert(Array.isArray(rv)).assert(0===rv.length);
if(wasm.bigIntEnabled && haveWasmCTests()){
const mI = wasm.xCall('sqlite3_wasm_test_int64_max');
const b = BigInt(Number.MAX_SAFE_INTEGER * 2);