You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rules that differ between dialects become named rules chosen when a statement is compiled #3170
alasql.options has six dialect flags (tsql, mysql, postgres, oracle, sqlite, orientdb), all true by default (src/engine/core.js). The files in src/dialects/ read them once at start-up, so changing a flag later does nothing. mysql.js adds TIMESTAMPDIFF and INFORMATION_SCHEMA, src/data/database.js adds tempdb for tsql, and the other files are empty.
The statement cache key is the SQL text plus joinstar (alasql.dexec in src/engine/core.js). The code generator has no named rule to read, so a step that switches a rule has no place to keep the old one.
What to change
Add a rule set on the engine. The defaults are today's behaviour.
alasql.load applies the modules in order and bumps a counter. The counter is part of the statement cache key.
Add modules at alasql/dialect/<name> for sqlite, postgres, mysql and mssql, and an empty alasql/dialect/v4. Move the code of src/dialects/*.js into them. TIMESTAMPDIFF, INFORMATION_SCHEMA and tempdb stay in the default.
Remove the six flags from alasql.options and their reads.
What stays the same
With no module loaded, every query gives the same result as before.
Only code that sets one of the six removed options changes.
Done when
A new test file named after this issue checks that the default rules give today's results, that loading a module with another rule value makes the same SQL text compile again with that rule, and that TIMESTAMPDIFF, INFORMATION_SCHEMA and tempdb work without loading anything.
The dialect test in test/dialect/ runs once for the default and once with the sqlite module loaded.
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.
Activity