fix(core): resolve compound primary key component metamodels to their columns#217
Merged
Merged
Conversation
… columns Component columns of a record-typed @pk are registered under the key's group metamodel so compound lookups return all key columns. The component's own metamodel is now retained as the column's secondary metamodel, which the column map already indexes, so the per-component metamodels exposed by generated metamodel classes and Key#flatten() resolve to their individual column in templates and predicates. Fixes #216
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Per-component metamodels of a compound primary key (
VetSpecialty_.id.specialtyId,Metamodel.of(VetSpecialty.class, "id.specialtyId"), and the leaves returned byKey#flatten()) fail template and predicate resolution withColumn not found for metamodel, even though the generated metamodel classes expose these nodes. See #216 for the full analysis.Root cause
ModelFactory#createColumnsregisters every component column of a record-typed@PKunder the key's group metamodel (via thekeyMetamodeloverride), so the column map carries no entry for the component's own canonical form. The component node is a scalar leaf, so the inline prefix fallback does not apply. Plain non-key inline records keep their own metamodels, which is whyOwner_.address.cityresolves while compound key components do not.Fix
When the key's group metamodel overrides a component column's addressing identity, the component's own metamodel is retained as the column's
secondaryMetamodel.ModelImpl#initColumnMapalready indexes secondary metamodels (the mechanism foreign keys use for their referenced-PK mirror), so component lookups resolve without any change to the lookup path:getColumns(id.specialtyId)→ the single component column,getColumns(id)→ all key columns, exactly as before (the group registration is untouched),Tests
ModelImplIntegrationTest#testVetSpecialtyCompoundPkComponentColumns: component lookups return their distinct single columns and the compound lookup still returns both.TemplatePreparedStatementIntegrationTest#testSelectCompoundPkComponent: aSELECT DISTINCTtemplate using a component metamodel compiles and executes.Full storm-core suite passes.
Fixes #216