Skip to content

Commit 57bfd90

Browse files
akoclaude
andcommitted
fix(odata): skip primitive-collection NPEs on Mendix <11.0 (10.24 nightly)
`create external entities from <odata client>` bulk-imports an OData contract and, for each Collection(Edm.X) property, creates a non-persistent entity backed by Rest$ODataMappedPrimitiveCollectionValue / Rest$ODataPrimitiveCollectionEntitySource (mirroring how Studio Pro handles e.g. TripPin Person.Emails). Those storage types are a Mendix 11.0 feature and do not exist in the 10.x type cache, so writing them made `mx check` on Mendix 10.24 abort the entire project load with: Mendix.Modeler.Storage.Caches.TypeCacheUnknownTypeException: The type cache does not contain a type with qualified name Rest$ODataMappedPrimitiveCollectionValue. (The 10.24 nightly failed 10-odata-examples on both engines for this reason.) Pre-11 Studio Pro simply omits OData primitive-collection properties when importing an external entity, so mirror that: gate createPrimitiveCollectionNPEs behind ProjectVersion().IsAtLeast(11, 0) and log a skip line on older projects. The rest of the external entities still import normally, so 10.24 keeps its external-entity coverage. On 11.x the NPEs are created exactly as before. Verified with the doctype gate: 10-odata-examples now passes on Mendix 10.24 (both engines) and still passes on 11.12 (NPEs created). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b258f48 commit 57bfd90

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

mdl/executor/cmd_contract.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -685,11 +685,23 @@ func createExternalEntities(ctx *ExecContext, s *ast.CreateExternalEntitiesStmt)
685685
// Second pass: create primitive-collection NPEs (e.g. TripTag for
686686
// Trip.Tags = Collection(Edm.String)) and the association from the
687687
// parent entity to each NPE.
688-
dm, err = ctx.Backend.GetDomainModel(module.ID)
689-
if err == nil {
690-
npesCreated := createPrimitiveCollectionNPEs(ctx, dm, doc, typeByQualified, esMap, serviceRef)
691-
if npesCreated > 0 {
692-
fmt.Fprintf(ctx.Output, "Created %d primitive-collection NPEs\n", npesCreated)
688+
//
689+
// OData primitive collections are a Mendix 11.0 feature: the backing
690+
// Rest$ODataMappedPrimitiveCollectionValue / Rest$ODataPrimitiveCollection*
691+
// storage types do not exist in the 10.x type cache, so writing them makes
692+
// `mx check` on Mendix 10.x abort the whole load with
693+
// TypeCacheUnknownTypeException. Pre-11 Studio Pro simply omits these
694+
// properties when importing an external entity, so mirror that: skip the NPEs
695+
// on < 11.0 (the rest of the entity imports normally).
696+
if pv := ctx.Backend.ProjectVersion(); pv != nil && !pv.IsAtLeast(11, 0) {
697+
fmt.Fprintf(ctx.Output, "Skipped primitive-collection NPEs (OData primitive collections require Mendix 11.0+; project is %s)\n", pv.ProductVersion)
698+
} else {
699+
dm, err = ctx.Backend.GetDomainModel(module.ID)
700+
if err == nil {
701+
npesCreated := createPrimitiveCollectionNPEs(ctx, dm, doc, typeByQualified, esMap, serviceRef)
702+
if npesCreated > 0 {
703+
fmt.Fprintf(ctx.Output, "Created %d primitive-collection NPEs\n", npesCreated)
704+
}
693705
}
694706
}
695707

0 commit comments

Comments
 (0)