Use LEFT JOIN When Checking for null Attributes
#14356
Merged
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.
Description
It is not possible to filter an EAV collection by an attribute being
null.Fixed Issues (if relevant)
nullAttribute Value #14355: Impossible to Filter Collection bynullAttribute ValueAlso addresses:
ProductFilterInputRequires Field to be a String #14312: GraphQLProductFilterInputRequires Field to be a StringManual testing scenarios
As addressed by the integration test, load a product collection and try to
addAttributeToFilterand select an attribute to benull. This is a correct usage of the API, and thewhereclause is generated correctly, as... WHERE ((at_special_price.value IS NULL)).However, without this diff, the join is an
INNER JOIN, which automatically excludesnullvalues.Discussion
I have chosen to add a little complexity here, by checking for a null comparison and only then selecting a
LEFT JOIN. It would work fine to use aLEFT JOINfor this all the time, but I suspect thatINNER JOINwas chosen for a reason, perhaps performance. I decided it was best to respect this decision and change as little as possible.Contribution checklist