[OPENJPA-2961] Include subclasses of the treated class in the TREAT discriminator filter - #189
Merged
Merged
Conversation
…iscriminator filter Build the TREAT condition through the discriminator strategy's class conditions, so that subclasses of the treated type are matched with an IN over their discriminator values.
solomax
reviewed
Sep 15, 2026
solomax
approved these changes
Sep 15, 2026
…EAT subclass test
Contributor
|
@rzo1 , could you add, in your tests, a revision number for both software and game, and a genre for game, and add the following tests? It seems to fail when using WHERE TREAT: |
…type A TREAT(x AS Type) path in a WHERE clause only overrode the metadata of the path, so rows of other types matched a predicate on an attribute they share with the treated type. As defined by the specification, such a predicate is now false if x is not an instance of Type or one of its subclasses. The restriction is added to the predicate containing the TREAT path, so other branches of an OR are not affected.
Contributor
Author
|
Thanks, good catch. The exclusive-property case only passed because |
cristof
approved these changes
Sep 15, 2026
Contributor
|
@solomax, as I've added some code, could you please review and merge? |
solomax
approved these changes
Sep 16, 2026
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.
The TREAT discriminator filter only matched the exact treated class (
disc = value), soTREAT(x AS Middle)dropped instances of Middle's subclasses. It now reuses the discriminator's class conditions, likeInstanceofExpression, which emitIN (...)over the treated class and its subclasses. Note that forLEFT JOIN TREAT(...)rows without a related entity are now kept (disc IS NULL OR ...);TestTreatSubclassDiscriminatorcovers a three-level single-table hierarchy.