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
Write the text of every expression from all of its parts, so unaliased column names are complete #2675
Each expression node writes its own toString() by hand (src/expression/). That text is the name of an unaliased result column (src/select/columns.js). Parts that a toString() leaves out are missing from the name, so two different expressions can get the same name and the second overwrites the first in the result row.
alasql("SELECT a LIKE 'x!%' ESCAPE '!' FROM ?",[[{a: 'x%'}]]);// [{"a LIKE 'x!%'": true}]
What to change
Every node class prints every child slot it declares in static children (Op.children = ['left', 'right', 'right1', 'right2', 'escape'] and the others). Fix the gaps the round-trip test finds. Known ones are ESCAPE in LIKE and the elements of ARRAY[...].
Print parentheses and spacing in one form, so that parsing the text again gives an equal node. Today NOT (a = 1 OR b = 2) prints NOT((a = 1 OR b = 2)) and a IS NOT NULL prints a IS NOT(NULL).
Unaliased column names change only where the old text left out a part or printed it in another form.
Done when
A new test file named after this issue has a round-trip test. For every SELECT the test suite parses, parse(toString(node)) equals node by structure (equals() on the base class).
It checks the column names of LIKE ... ESCAPE, ARRAY[...], NOT (...) and IS NOT NULL.
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.
Another instance of the same pattern, found while reviewing #2195: each node lists its child expressions by hand in every walker, so a node with extra parts gets missed. Op.findAggregator did not walk right1 / right2 of BETWEEN until #2195 added it. One list of child expressions per node, used by toString(), findAggregator and the other walkers, would close this class with the toString() gaps.
2026-10-21: #2674 (ESCAPE in the text) and #2691 (ARRAY[...] elements in the text) changed the names of unaliased columns, which existing code may rely on, so they are reverted for 4.x in #2750 and come back in 5.0 with this issue. Their tests are in the reverted PRs.
changed the title [-]Review #1197 for code improvements: toString() is used as the identity of an expression[/-][+]Write the text of every expression from all of its parts, so unaliased column names are complete[/+]on Nov 26, 2026
Activity
mathiasrw commentedon Oct 20, 2026
Another instance of the same pattern, found while reviewing #2195: each node lists its child expressions by hand in every walker, so a node with extra parts gets missed.
Op.findAggregatordid not walkright1/right2ofBETWEENuntil #2195 added it. One list of child expressions per node, used bytoString(),findAggregatorand the other walkers, would close this class with thetoString()gaps.mathiasrw commentedon Oct 21, 2026
2026-10-21: #2674 (
ESCAPEin the text) and #2691 (ARRAY[...]elements in the text) changed the names of unaliased columns, which existing code may rely on, so they are reverted for 4.x in #2750 and come back in 5.0 with this issue. Their tests are in the reverted PRs.[-]Review #1197 for code improvements: toString() is used as the identity of an expression[/-][+]Write the text of every expression from all of its parts, so unaliased column names are complete[/+]