Skip to content

Commit e424eaa

Browse files
akoclaude
andcommitted
fix: resolve association/attribute and entity/enumeration ambiguity (#50)
Bug 1: CREATE/CHANGE OBJECT wrote associations into the Attribute field because the dot-contains heuristic failed for unqualified names like Child_Parent. New resolveMemberChange() queries the domain model to determine if a member is an association or attribute. Handles both bare names (Order_Customer) and already-qualified names (MfTest.Order_Customer) without double-qualifying. Bug 2: DECLARE with entity types produced DataTypes$EnumerationType instead of DataTypes$ObjectType because the visitor cannot distinguish entities from enumerations. The executor now resolves this ambiguity by checking the domain model via isEntity(). Both fixes fall back gracefully when no reader is available. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4fda6ed commit e424eaa

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

mdl/executor/cmd_microflows_builder_actions.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@ func (fb *flowBuilder) isEntity(moduleName, entityName string) bool {
745745
// and sets the appropriate field on the MemberChange. It queries the domain model
746746
// to check if the name matches an association on the entity; if no reader is available,
747747
// it falls back to the dot-contains heuristic.
748+
//
749+
// memberName can be either bare ("Order_Customer") or qualified ("MfTest.Order_Customer").
748750
func (fb *flowBuilder) resolveMemberChange(mc *microflows.MemberChange, memberName string, entityQN string) {
749751
if entityQN == "" {
750752
return
@@ -758,25 +760,40 @@ func (fb *flowBuilder) resolveMemberChange(mc *microflows.MemberChange, memberNa
758760
}
759761
moduleName := parts[0]
760762

763+
// If memberName is already qualified (e.g., "MfTest.Order_Customer"),
764+
// extract the bare name for association lookup.
765+
bareName := memberName
766+
qualifiedName := memberName
767+
if dot := strings.Index(memberName, "."); dot >= 0 {
768+
bareName = memberName[dot+1:]
769+
// qualifiedName is already set to the full memberName
770+
} else {
771+
qualifiedName = moduleName + "." + memberName
772+
}
773+
761774
// Query domain model to check if this member is an association
762775
if fb.reader != nil {
763776
if mod, err := fb.reader.GetModuleByName(moduleName); err == nil && mod != nil {
764777
if dm, err := fb.reader.GetDomainModel(mod.ID); err == nil && dm != nil {
765778
for _, a := range dm.Associations {
766-
if a.Name == memberName {
767-
mc.AssociationQualifiedName = moduleName + "." + memberName
779+
if a.Name == bareName {
780+
mc.AssociationQualifiedName = qualifiedName
768781
return
769782
}
770783
}
771-
// Also check cross-associations
772784
for _, a := range dm.CrossAssociations {
773-
if a.Name == memberName {
774-
mc.AssociationQualifiedName = moduleName + "." + memberName
785+
if a.Name == bareName {
786+
mc.AssociationQualifiedName = qualifiedName
775787
return
776788
}
777789
}
778790
// Not an association — it's an attribute
779-
mc.AttributeQualifiedName = entityQN + "." + memberName
791+
if strings.Contains(memberName, ".") {
792+
// Already qualified, don't double-qualify
793+
mc.AttributeQualifiedName = memberName
794+
} else {
795+
mc.AttributeQualifiedName = entityQN + "." + memberName
796+
}
780797
return
781798
}
782799
}

0 commit comments

Comments
 (0)