{"area": "mdl/executor", "date": "2026-09-12", "symptom": "A view entity cannot be given an association to a persistent entity. Three separate failures: (a) `mxcli check` misreports types — with the id column first, \"attribute 'TotalKwh': declared as Decimal but OQL expression returns Integer\"; with it last, \"OQL select has 4 columns but 3 attributes declared\"; (b) `exec` writes the view entity and creates NO association member, so the build fails CE1613 \"The selected association 'X' no longer exists\" (11.13/11.14) or CE6770 \"View Entity is out of sync with the OQL Query\" (10.24); (c) adding it by hand with `create association` gives CE6771 \"It is not possible to create associations to/from View Entities\"", "cause": "Selecting a persistent entity's id under an alias gives a view entity an ASSOCIATION whose name is the alias — the column IS the declaration, and Studio Pro creates the member when the column is added. mxcli modelled the select list as attributes only. (a) columns are aligned with declared attributes BY POSITION, so an unrecognised id column SHIFTS every attribute after it; (b) nothing created the member; (c) the association Studio Pro writes carries `Source: {$Type: DomainModels$OqlViewAssociationSource, Reference: <alias>}` and mxcli wrote `Source: null` — the `default:` arm of the source switch in both engines' association serializers", "file": "`mdl/executor/oql_view_associations.go` (new), `mdl/executor/cmd_entities.go` (execCreateViewEntity), `mdl/executor/oql_type_inference.go` (extractAliasMap, the two alignment sites), `mdl/executor/cmd_associations.go` + `validate.go` (CE6771 refusal), `sdk/domainmodel/domainmodel.go` (OqlViewAssociationSource, Association/CrossModuleAssociation.ViewSourceReference), `sdk/mpr/{parser,writer}_domainmodel.go`, `mdl/backend/modelsdk/{domainmodel,domainmodel_write,association_move_write}.go`", "insight": "**One field clears two errors, and measuring that first was the whole plan.** Before writing any Go: build the broken model with mxcli, apply the reporter's python patch that adds only the Source subdocument, re-run `mx check` — 2 errors (CE6771 + CE6770) to 0 on 11.13.0. That proves the target shape AND proves the association is also what makes the id column legal on the view entity, which no amount of reading would have settled. **Derive the association from the OQL rather than inventing syntax**: the column is the declaration, so describe → exec round-trips with no second statement to keep in step (verified: describe into a fresh project, 0 errors). **Correction to the report**: it says Studio Pro writes a `CrossAssociation`; that is true only when the target is in ANOTHER module — same-module is a plain `Association`, and both needed the field, so a fix pinned to CrossAssociation alone would have worked for one project layout and not the other. **The read path is not optional**: `create or modify association` round-trips through the semantic model and wrote `Source: null` back, silently converting a working project into CE6771 — A/B'd (pre-fix `Source = null`, fixed `Unchanged association`). The ALTER path does NOT lose it, because it gen-mutates the stored document, so the loss is narrower than the report implies but real. **Two alias-resolution gaps found by running the reporter's own example**: `extractAliasMap` matched neither `join r/Mod.Assoc/Mod.Target as m` (association-path join — the ordinary way to reach a related entity) nor `from Mappings.\"Order\" as o` (a quoted reserved word — the only way to write that entity), so the reported case resolved to nothing and produced no association at all. Run the reporter's literal example, not a tidied one. **`cast(m.ID as string)` must NOT be treated as an association** — it is a legitimate flat design (one query instead of two, no objects materialised in the client), so detection is the bare `<alias>.ID` form only. Measured on 11.13.0, both engines, 0 errors; controls: pre-fix binary on the same script gives 2 × CE1613, and re-running is `Unchanged`. Example `mdl-examples/bug-tests/view-entity-association.mdl`; tests `oql_view_associations_test.go`, `sdk/mpr/writer_domainmodel_test.go`. Reported by ako/view-entity-examples FINDINGS §1", "ce": ["CE6770", "CE6771", "CE1613"], "refs": ["ako/view-entity-examples"]}
0 commit comments