|
| 1 | +-- ============================================================================ |
| 2 | +-- Bug #358: Validation feedback object and association targets |
| 3 | +-- ============================================================================ |
| 4 | +-- |
| 5 | +-- Symptom (before fix): |
| 6 | +-- Microflow `validation feedback` statements can target an object |
| 7 | +-- itself or an association member, not only a scalar attribute. The |
| 8 | +-- MDL grammar accepted only attribute paths, and the formatter |
| 9 | +-- emitted only attribute targets. Round-tripping object-only and |
| 10 | +-- association targets either failed to re-parse the described MDL or |
| 11 | +-- dropped the association name when describing existing Studio Pro |
| 12 | +-- models. |
| 13 | +-- |
| 14 | +-- After fix (grammar + formatter only): |
| 15 | +-- - Grammar now accepts `validation feedback $Object message '…';` |
| 16 | +-- (object-only target). |
| 17 | +-- - Grammar treats each path segment of `$Object/Module.Member` as a |
| 18 | +-- qualified name so `Module.Association` stays one association |
| 19 | +-- segment. |
| 20 | +-- - Formatter emits `AssociationName` when `AttributeName` is absent, |
| 21 | +-- preserving association targets when describing existing models. |
| 22 | +-- |
| 23 | +-- Scope note: |
| 24 | +-- This PR fixes the parser and the formatter (describe path) so |
| 25 | +-- existing models with object-only or association targets re-parse |
| 26 | +-- and re-describe cleanly. It does NOT extend the builder to make |
| 27 | +-- newly authored object-only targets a valid Studio Pro model — the |
| 28 | +-- builder still emits `Attribute = ""` which Studio Pro rejects with |
| 29 | +-- `[CE0091] No member selected`. Authored validation feedback should |
| 30 | +-- continue to use the attribute form until a follow-up extends the |
| 31 | +-- builder. |
| 32 | +-- |
| 33 | +-- Usage (verifies the in-scope fix): |
| 34 | +-- ./bin/mxcli check mdl-examples/bug-tests/358-validation-feedback-targets.mdl |
| 35 | +-- ./bin/mxcli exec mdl-examples/bug-tests/358-validation-feedback-targets.mdl -p app.mpr |
| 36 | +-- ./bin/mxcli -p app.mpr -c "describe microflow BugTest358.MF_ValidateAttr" |
| 37 | +-- The describe output must keep `validation feedback $Customer/Email |
| 38 | +-- message '…';` and `mx check` must report 0 errors. |
| 39 | +-- |
| 40 | +-- The OBJECT-ONLY shape `validation feedback $Customer message '…';` |
| 41 | +-- parses and re-describes cleanly (covered by parser/formatter Go tests), |
| 42 | +-- but mx check will still surface `[CE0091]` because the builder is |
| 43 | +-- out of scope here. Authored MDL should keep using the attribute form. |
| 44 | +-- ============================================================================ |
| 45 | + |
| 46 | +create module BugTest358; |
| 47 | + |
| 48 | +create entity BugTest358.Customer ( |
| 49 | + Email : string(200) |
| 50 | +); |
| 51 | +/ |
| 52 | + |
| 53 | +-- Attribute-target validation feedback — must round-trip cleanly under |
| 54 | +-- describe → exec → describe and pass `mx check`. |
| 55 | +create microflow BugTest358.MF_ValidateAttr ( |
| 56 | + $Customer: BugTest358.Customer |
| 57 | +) |
| 58 | +returns boolean as $Valid |
| 59 | +begin |
| 60 | + declare $Valid boolean = true; |
| 61 | + if $Customer/Email = empty then |
| 62 | + set $Valid = false; |
| 63 | + validation feedback $Customer/Email message 'Email is required'; |
| 64 | + end if; |
| 65 | + return $Valid; |
| 66 | +end; |
| 67 | +/ |
0 commit comments