|
| 1 | +-- ============================================================================ |
| 2 | +-- Bug #360: Import-from-mapping result variable type was not registered |
| 3 | +-- ============================================================================ |
| 4 | +-- |
| 5 | +-- Symptom (before fix): |
| 6 | +-- `import from mapping` actions wrote the correct |
| 7 | +-- `Forms$ResultHandlingMapping` BSON, but the builder did not register |
| 8 | +-- the inferred result type onto the output variable in its variable |
| 9 | +-- scope. Subsequent activities that touched the imported result |
| 10 | +-- (`change`, `commit`, `$Var/Attribute`, association paths) ran without |
| 11 | +-- type info, which caused: |
| 12 | +-- - the writer to fall back to untyped expressions |
| 13 | +-- - re-describes to lose the right declaration shape |
| 14 | +-- - downstream activities to fail with CE0117 in Studio Pro |
| 15 | +-- |
| 16 | +-- After fix: |
| 17 | +-- `addImportFromMappingAction` now also writes the result type into |
| 18 | +-- `flowBuilder.varTypes`. When the mapping's JSON structure produces a |
| 19 | +-- single object, the variable becomes `Module.Entity`. When it produces |
| 20 | +-- an array, the variable becomes `List of Module.Entity`. The |
| 21 | +-- ResultHandlingMapping BSON path is unchanged. |
| 22 | +-- |
| 23 | +-- Usage: |
| 24 | +-- mxcli exec mdl-examples/bug-tests/360-import-mapping-result-type.mdl -p app.mpr |
| 25 | +-- mxcli -p app.mpr -c "describe microflow BugTest360.MF_ImportPet" |
| 26 | +-- `mx check` against the resulting MPR must report 0 errors and the |
| 27 | +-- `change $Pet (...)` statement after the import must resolve. |
| 28 | +-- ============================================================================ |
| 29 | + |
| 30 | +create module BugTest360; |
| 31 | + |
| 32 | +create json structure BugTest360.JSON_Pet |
| 33 | +snippet '{"id": 1, "name": "Fido", "status": "available"}'; |
| 34 | + |
| 35 | +create non-persistent entity BugTest360.PetResponse ( |
| 36 | + PetId : integer, |
| 37 | + Name : string, |
| 38 | + Status : string |
| 39 | +); |
| 40 | +/ |
| 41 | + |
| 42 | +create import mapping BugTest360.IMM_Pet |
| 43 | + with json structure BugTest360.JSON_Pet |
| 44 | +{ |
| 45 | + create BugTest360.PetResponse { |
| 46 | + PetId = id, |
| 47 | + Name = name, |
| 48 | + Status = status |
| 49 | + } |
| 50 | +}; |
| 51 | + |
| 52 | +-- Caller — uses the imported `$Pet` in a downstream `change`. Without |
| 53 | +-- the result-type registration, the change activity has no resolved |
| 54 | +-- entity for `Status` and Studio Pro surfaces CE0117. |
| 55 | +create microflow BugTest360.MF_ImportPet ( |
| 56 | + $Json: string |
| 57 | +) |
| 58 | +returns BugTest360.PetResponse as $Pet |
| 59 | +begin |
| 60 | + $Pet = import from mapping BugTest360.IMM_Pet ($Json); |
| 61 | + |
| 62 | + if $Pet != empty then |
| 63 | + change $Pet (Status = $Pet/Status + ' (processed)'); |
| 64 | + end if; |
| 65 | +end; |
| 66 | +/ |
0 commit comments