APIv4 - Specify BridgeEntities to assist with joins #17808
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.
Overview
In our schema we have these tiny tables like
civicrm_entity_tag
which serve no purpose other than to "bridge" 2 other tables together. Arguably they don't deserve to be their own API entities, but what I've done here is to at least distinguish them as "bridge" entities so they can receive separate treatment in search screens.I've also taught the API to create joins through these bridge entities with a fairly simple syntax that, to the API consumer, only feels like 1 join, when behind the scenes the api constructs both joins and figures out which FKs link the 3 tables together.
Comments
This gets us closer to having things like Activities and Tags in the new SearchCreator. It still doesn't solve the problem of groups, which use 2 tables + caching to deal with smart groups. It also doesn't yet solve the problem of getting these things easily discoverable in the SearchCreator UI, but it's a step in the right direction.