Add support for a list of taggable IDs in the tagging conditions #1053
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.
In the event of trying to fetch tags for multiple records, where the IDs of those records are already known, adding support for the
:id
option to accept an array of IDs to use directly, instead of using a subquery to find the same list of IDs.I had run into a situation, where I was trying to get the tags for a series of records associated to the ones I was listing, and SQL resulting from calling
tag_counts_on
was using a subquery to fetch the IDs that were already being used in the query chain.For example, say I was listing cases for multiple projects, and wanted to be able to filter those cases by tags on the projects. If I did:
... it would result in a SQL that used the following sub-query:
This is causing the database to do extra work. There's an option that can be used to pass in an ID to
tag_counts_on
, but it currently only works with a single ID. This PR aims to extend that option to support an array of IDs as well, so the following could be used:... and have the generated SQL be this instead: