Advanced-mode SELECT: aggregation functions (sum/avg/count/min/max) execute correctly but are highlighted red and the line marked [ERR]
#6
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Observed
select sum(Age) from Customers(advanced mode):sumis highlighted red in the echoed input, and the line is marked[ERR].Same behaviour expected for
avg,count,min,max.Cause (likely)
Aggregation function calls are not yet covered by the SELECT expression grammar / validator (ADR-0031 / ADR-0033 §3). The engine runs the SQL (SQLite accepts it), but the in-app static analysis flags the call as unknown.
Expected
Aggregations should be a recognised expression form in advanced-mode SELECT — no red highlight, no
[ERR]marker on a statement that ran successfully.Scope decision
group_concat,total,coalesce)?sum(distinct …),count(*)?GROUP BY/HAVINGsupport is a separate question — out of scope here unless raised.Resolved in commit
24c2685.Two layered fixes in the same bug class:
Walker (
schema_existence_diagnostics): the bare-column check onsql_expr_identitems now skips when the ident is immediately followed by(— it's a function-call name, not a column reference. New helperis_followed_by_call_argsmirrors the existingis_followed_by_qualified_refguard. Cascades to the[ERR]indicator, the red highlight overlay, and the diagnostic-driven ambient hint.Typing-time (
invalid_ident_at_cursor_in_mode): early-return atsql_expr_identpositions — the partial could resolve to either a column or a function name; without lookahead for a trailing(we can't tell. Submit-time still catches genuine column typos via the schema-existence diagnostic andpick_hint_diagnostic.Scope question in the original body turned out to be moot — the fix is all function calls, not an enumerated aggregate list. Matches ADR-0031 §1's stated posture ("the grammar admits the call shape structurally; it does not know which names are aggregates"). Tests added: 5 (walker positives covering every standard aggregate +
count(*)+count(distinct …)+ nested + WHERE + non-aggregate functions; walker negatives for unknown column inside args and inside DISTINCT-shielded args; typing-time positive; typing-time trade-off lockdown).Two adjacent enhancement trackers filed for points outside the bug-fix scope:
Full suite 2040 passed / 0 failed / 0 unexpected skips. Clippy clean.