Skip to content

fix(check): view-entity OQL checks for CE0174/CE6770, runtime GROUP BY errors and HSQLDB literals (#981) - #984

Merged
ako merged 9 commits into
mainfrom
fix/981-view-entity-oql-checks
Oct 4, 2026
Merged

ako merged 9 commits into
mainfrom
fix/981-view-entity-oql-checks

Conversation

@ako

@ako ako commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

Closes #981

View-entity OQL that check passed and mxbuild or the runtime refused. Each rule's failing forms and controls are measured on mxbuild 11.13.0 (the issue's JTSBootLogboek H16/H18 views, plus a new probe set on the same app, below).

Item Rule Severity Measured outcome it predicts
1 comparison as a column (r.Season = r.CurrentSeason as IsCurrent, also !=) MDL033 error CE0174 "The '=' part is incomplete or incorrect"; suggests case when … then true else false end
2 aggregate reads a column a GROUP BY expression uses (count(r.Season) by r.Season, max(r.RaceDate) by datepart(YEAR, r.RaceDate), sum(r.Season) by r.Season + 1) MDL034 error CE0174
3 plain column neither aggregated nor grouped MDL035 error CE0174 "Every expression in the SELECT clause must be included in the GROUP BY clause"
6 non-aggregated expression that does not match a GROUP BY expression MDL036 error passes mxbuild; PostgreSQL 42803 / HSQLDB 42574 at runtime (issue measurement)
7a literal aggregate argument (sum(1), count(1), max(0), count('x'), count(true), sum(0.0), sum(1.5), max(0.0)) MDL037 warning HSQLDB 42567 "data type cast needed" (measured); decimals included — only a decimal select column is cast. avg(1) is not flagged: it runs on HSQLDB (measured), Mendix's avg returning Decimal so its argument reaches the database typed
7b bare integer/string literal select column MDL038 info v.One + 1 = 11 on HSQLDB, 2 on PostgreSQL (issue measurement); suggests cast(… as Integer/String)
4 declared autonumber over an AutoNumber column MDL-V1-VIEWAUTONUMBER error under mdl 1;, warning without the header (ADR-0011, langver.Change) CE6770; suggests Long
5 r.Name + ' x' MDL031 (type inference) error String(200) builds; string, string(100), string(102) are CE6770
8 write-oql-queries skill — — a view entity has no ID: count a non-null column; GROUP BY / HSQLDB table added

MDL033–036 live in ValidateOQLSyntax, so exec refuses them too. MDL037/038 are in a new ValidateOQLPortability that only check and the LSP call — exec turns every ValidateOQLSyntax finding into a refusal, whatever its severity. 'TOTAL' as Label (used in the docs) draws only the MDL038 note; make check-mdl / check-skill-mdl stay clean. No doc example aggregated a literal, so none needed the cast form.

Fix along the way: check's reference tier (ValidateProgram[WithWarnings]) ran with language version 0 regardless of the script header; it now enters the program's version, which is what makes the AutoNumber gate work from check -p --references.

New measurements (mx check 11.13.0, copy of the issue's app)

  • CE0174: r.Name next to group by r.Season; r.Name next to group by r.ID (no functional-dependency exemption); the same in from-first clause order; r.Season != r.CurrentSeason as X.
  • 0 errors (controls): datepart(YEAR, r.RaceDate) + 1 next to group by datepart(YEAR, r.RaceDate); group by Yr (select alias); 'x' as L next to a GROUP BY; r.Season, r.Name, count(r.Points) by both; 'Season ' + r.Name declared string(200).

Test plan

  • go test ./mdl/executor/ (full package) — pass; new tests in oql_view_select_checks_test.go (one per rule MDL033–038, each with the measured passing forms as controls) and oql_view_column_types_test.go (concatenation, AutoNumber under V1/V0 with Long controls).
  • go test ./cmd/mxcli/ ./mdl/migration/ ./mdl/linter/ — pass.
  • make build, make lint, make check-conformance, make check-findings, make check-migration-reference (versions.md regenerated), make sync-skills, make check-mdl, make check-skill-mdl — all pass. (check-mdl first caught a normalisation bug — cast(m.ID as string) read as column m.idasstring — fixed, with a control test.)
  • End to end, mxcli check -p … --references on the issue's scratch views (V1cmp, V2aggInGroupExpr, V2bSum, V3count, V3sum1, V4col, V4nonagg, V5autoAN, h13) reports the expected rule; V1case, V3countName, V4alias, V5autoLong, V5cast pass; V5autoAN without the header gives the MDL-V1-VIEWAUTONUMBER warning only.
  • Revert checks (each guard disabled in turn, the matching test run): MDL033, MDL034, MDL035/036, MDL037 (incl. the decimal branch and the avg exemption, separately), MDL038, concatenation and the AutoNumber gate each fail their test with the reported symptom; restored afterwards.

Notes / follow-up

  • GROUP BY rules skip UNION queries (each branch has its own list) and subquery columns; unqualified column names (no alias.) are not recognised as columns, so they are never flagged.

🤖 Generated with Claude Code

ako and others added 9 commits October 4, 2026 18:52
formatDecimal(x, '0.00') follows the user's language, so a Dutch user got
12,50 and invalid JSON. Use toString(round(x, 2)), or formatDecimal with a
hyphenated locale; explain the silently-ignored underscore tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…json (#982)

The run --local hint 'mxcli oql -p …' failed on a non-default --admin-port
(cannot connect … localhost:8090), and mxcli log did the same. Both now take
the port and password from a live .mxcli/run-local.json for any flag not given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ilt JSON (#982)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…refuses

MDL033 comparison as a select column (CE0174), MDL034 aggregate over a
grouped column (CE0174), MDL035 plain column not grouped (CE0174),
MDL036 non-aggregated expression not in the GROUP BY (passes mxbuild,
PostgreSQL 42803 / HSQLDB 42574 at runtime) - errors in ValidateOQLSyntax.
MDL037 literal aggregate argument (HSQLDB 42567, warning) and MDL038 bare
integer/string literal column (info) in ValidateOQLPortability, which only
check and the LSP run. Part of #981.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
String concatenation (r.Name + ' x') is a derived String(200) in mxbuild;
string / string(100) declarations are CE6770 and now MDL031. A view
attribute declared autonumber over an AutoNumber column (CE6770) is
refused under mdl 1 and warns MDL-V1-VIEWAUTONUMBER without the header
(ADR-0011); check's reference tier now runs under the script's language
version. Part of #981.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
write-oql-queries: a view entity has no ID (count a non-null column), the
GROUP BY / comparison / HSQLDB literal table, String(200) concatenation,
AutoNumber -> Long.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sum(0.0) and sum(1.5) fail on HSQLDB with 42567 like the integer forms;
only a decimal select COLUMN is cast by Mendix (MDL038 still skips it).
avg(1) runs on HSQLDB and stays unflagged. Part of #981.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ako
ako merged commit 7d0f7dc into main Oct 4, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

View entity OQL: check misses CE0174/CE6770 cases, runtime-only GROUP BY errors, and bare literals that break on HSQLDB (1+1 = 11)

1 participant