Repository navigation
Open
0 / 30 of 3 issues completedOpen
0 / 30 of 3 issues completed
Copy link
Labels
Milestone
Description
What happens today
queryfn(src/select/queryfn.js, line 37) calls each source'sdatafnwithqueryfn2(line 97) as callback, which counts downquery.sourceslenand callsqueryfn3(line 119). Only the branch without sources wrapsqueryfn3intry(line 87), so an error after an asynchronous source escapes. This is alasql.promise over a file source never settles when a user function throws #3155.alasql.adrun(src/engine/core.js, line 644) passes each statement's result to the next and goes on after an error. This is alasql.promise with several statements in one string resolves with null for a statement that throws #3156.- The statement cache in
alasql.dexec(src/engine/core.js, line 517) anddb.astCacheare keyed on the SQL text plusalasql.options.joinstar(line 525).casesensitive,valueof,autocommitandcacheare read at parse or compile time but are not in the key. This is Changing alasql.options.casesensitive keeps using statements compiled under the old setting #3157.
What to change
- Add
runQuery(run, ctx)insrc/select/queryfn.js. It opens every source through the source interface of Give file sources one source interface that opens rows for a run and reports errors in one place #2677 (open(ctx)gives an array or a promise of one). When every source gave an array it continues at once, otherwise it waits withPromise.alland continues along the same path. Removequeryfn2and thesourceslencounter. - Wrap everything after the sources in one
tryin the runner. With a callback the error goes tocb(null, err)once, without one it is thrown. alasql.adrunstops at the first statement that reports an error and passes the error to the callback.- Add
cacheKey(sql)insrc/engine/core.jsthat joins the SQL text withjoinstar,casesensitive,valueof,autocommitandcache, and use it fordb.sqlCacheanddb.astCache. Keep the option names in one list with a comment that a new compile-time option belongs in it.
What stays the same
- Every result of a statement that succeeds, synchronously and asynchronously, and the order of the results of several statements.
- A plain
alasql(sql)without a callback over a source that answers later still returnsundefined. - The
(data, err)order of alasql callbacks. - Results change only for alasql.promise over a file source never settles when a user function throws #3155, alasql.promise with several statements in one string resolves with null for a statement that throws #3156 and Changing alasql.options.casesensitive keeps using statements compiled under the old setting #3157.
Done when
- A new test file named after this issue checks that
alasql.promiserejects, within a time limit, for an error in a user function, in ORDER BY and in a scalar subquery over a file source, and for the second of two statements, and that the callback form gets the error once. - The same file switches each option in the cache key between two runs of the same SQL text and checks that the second run matches a run with the cache off.
- The full test suite and the CI checks (dialect test, parity check, run-state check, binding check) pass, and the pull request lists every parity difference.
Fixes
Depends on
Sub-issues
Collapse Sub-issuesSub-issues
Loading 3 sub-issues
Activity
mathiasrw commentedon Oct 20, 2026
Measured while reviewing #909, on
develop: withalasql.options.casesensitive = false, runSELECT Name FROM ?over[{Name: "x"}](gives[{}], the name is lowercased). Setcasesensitive = trueand run the same text again: still[{}], because the cached statement was compiled with the lowercased name. A fresh process withcasesensitive = truegives[{Name: "x"}].[-]Review #2312 for code improvements: one option in the statement cache key[/-][+]Run a statement through one runner so every error reaches the caller, and key the statement cache on every compile option[/+]