APIv4 - Smarter check for adding default ON clause to explicit joins #19275
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.
Overview
Allows greater flexibility in how explicit joins are performed in APIv4
See https://lab.civicrm.org/dev/core/-/issues/2271
Before
Default ON clause added to any join without an ID specified already in its clauses.
After
Default ON clause added to any join without an ID OR an FK field specified.
Technical Details
When adding explicit joins in APIv4, the API will automacially add an ON clause linking it to the base entity unless it detects some other link already present in the ON clause supplied.
Previously it would determine this by checking for the join entity ID;
Now it looks for the join entity ID OR any other field in the join entity with an FK.
This gives more leeway for people to add creative joins without the defaults getting in the way.