Skip to content

fix: emit correct enum value format for XPath vs expression contexts#167

Open
engalar wants to merge 1 commit intomendixlabs:mainfrom
engalar:fix/enum-value-context-syntax
Open

fix: emit correct enum value format for XPath vs expression contexts#167
engalar wants to merge 1 commit intomendixlabs:mainfrom
engalar:fix/enum-value-context-syntax

Conversation

@engalar
Copy link
Copy Markdown
Contributor

@engalar engalar commented Apr 10, 2026

Summary

  • XPath context (RETRIEVE WHERE): 3-part enum refs like Module.EnumName.Value now emit 'Value' (quoted value only) instead of the full qualified name
  • Expression context (CHANGE/CREATE): string literal enum values like 'Processing' are resolved to Module.EnumName.Processing when the attribute type is an enumeration (requires MPR context)
  • Same fix applied to page data source XPath handler (xpathExprToString)

Test plan

  • TestQualifiedNameToXPath_EnumValue — 3-part name → 'Value'
  • TestQualifiedNameToXPath_NonEnum — 2-part name passes through
  • TestExpressionToXPath_EnumInComparison — full WHERE clause roundtrip
  • TestExpressionToXPath_StringLiteralPreserved — string literals unchanged
  • TestExpressionToString_QualifiedNameUnchanged — expression context keeps qualified name
  • TestXPath_EnumValueReference — visitor XPath roundtrip (3 sub-tests)
  • Full go test ./mdl/... passes with 0 failures

Fixes #125

Enum values require different serialization depending on context:
- XPath (RETRIEVE WHERE): 'Value' (quoted value name only)
- Expression (CHANGE/CREATE): Module.EnumName.Value (qualified)

Fixes mendixlabs#125
@github-actions
Copy link
Copy Markdown

AI Code Review

What Looks Good

  • Comprehensive test coverage: New test file cmd_microflows_helpers_test.go with 5 test functions covering enum value handling in XPath vs expression contexts, plus additional tests in visitor_xpath_test.go. All tests pass as reported.

  • Correct contextual handling: The fix properly distinguishes between XPath context (where 3-part enum refs like Module.Enum.Value should emit 'Value') and expression context (where string literals like 'Processing' should resolve to Module.EnumName.Processing for enum attributes).

  • Minimal, focused changes: The PR addresses exactly the issue described (Enum value syntax differs between XPath and expression contexts #125) without unnecessary modifications. Changes are confined to the relevant executor and visitor components.

  • Proper helper extraction: New functions (qualifiedNameToXPath, memberExpressionToString, lookupEnumRef) encapsulate the logic cleanly, making the code easier to understand and maintain.

  • Error handling: The lookupEnumRef function includes appropriate nil checks and gracefully falls back to standard behavior when the domain model isn't available.

  • Consistency: Both microflow actions (CreateObject/ChangeObject) and page data source XPath handling now use the same corrected logic.

  • No syntax changes: Since this fixes existing behavior rather than adding new MDL syntax, the syntax design and full-stack consistency checklist items don't apply (no grammar/AST/LSP changes needed).

Recommendation

The PR is ready to approve. It correctly resolves the enum value formatting issue in both XPath and expression contexts with appropriate test coverage and minimal, focused changes that maintain backward compatibility. No issues were found against the review checklist.


Automated review via OpenRouter (Nemotron Super 120B) — workflow source

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.

Enum value syntax differs between XPath and expression contexts

1 participant