engine: Support for 'AND' and 'not equal' expressions for objects with multiple tags - #1008
Open
klskvmr wants to merge 1 commit into
Open
engine: Support for 'AND' and 'not equal' expressions for objects with multiple tags#1008klskvmr wants to merge 1 commit into
klskvmr wants to merge 1 commit into
Conversation
klskvmr
requested review from
ahadas,
bennyz,
didib,
emesika,
michalskrivanek,
mwperina,
sgratch and
smelamud
as code owners
April 11, 2025 12:01
klskvmr
marked this pull request as draft
April 12, 2025 06:06
klskvmr
force-pushed
the
support-search-with-multiple-tags-conditions
branch
from
April 14, 2025 08:31
fda1798 to
8b031a9
Compare
The tags columns types in *_with_tags views have been changed from text to arrays for support and improve tags searching with multiple conditions without increasing the complexity of the resulting SQL query. Signed-off-by: Mari Istomina <koloskova.marii@gmail.com>
klskvmr
force-pushed
the
support-search-with-multiple-tags-conditions
branch
from
April 14, 2025 08:37
8b031a9 to
db6d06a
Compare
0ffer
approved these changes
Apr 14, 2025
klskvmr
marked this pull request as ready for review
April 14, 2025 14:42
Author
Author
JasperB-TeamBlue
requested review from
JasperB-TeamBlue,
dupondje and
sandrobonazzola
and removed request for
ahadas,
bennyz,
didib,
emesika,
michalskrivanek,
mwperina and
smelamud
April 15, 2025 07:36
JasperB-TeamBlue
approved these changes
Apr 16, 2025
JasperB-TeamBlue
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me, only thing that bothers me is that the tag string used as a parameter in the expressions is capital sensitive while this is not the case for expressions regarding the name of a vm. Due to this not being a previous functionality on the main branch it does not concern the scope of this patch.
0ffer
approved these changes
May 29, 2025
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.




AND condition problem
The tag filter did not work for objects with multiple tags in the following cases:
AND!=operatorReason:
Previously, inside the
*_with_tagsviews (used for searching by tags), a left join was made with thetags_*views (containing the tags), and for each tag of one entity there was a separate row in the table.Tags for one entity were in different rows and the condition with
INdid not work, since it works by rows.Example:
WHERE ( vms_with_tags.tag_name IN ('tag-1') AND vms_with_tags.tag_name IN ('tag-2') )this condition will always be false for objects with multiple tags.
What was done to solve the problem
The tags columns types in
*_with_tagsviews have been changed from text to arrays for support and improve tags searching with multiple conditions without increasing the complexity of the resulting SQL query.To support filtering by tags, it was decided to use arrays. Now, to search for one or more tags, the array intersection operation (&&) is used, which allows for the correct use of several consecutive conditions with tags
The edits affected tag filters on the pages:
Cases
All functionality is preserved, only a filter by several tags via AND is additionally supported.
Objects with the searched tag and objects with its nested tags.
Nested tags are taken into account!
i.e. tags nested in the searched tag will also be included in the resulting selection
Objects not marked with the tag from the condition.
Nested tags are not taken into account!
<, >, <=, >=
Objects with the searched tags and objects with tags nested in them.
Nested tags are taken into account!
Objects containing all the searched tags or tags nested in them.
Nested tags are taken into account!
e.g. tag = test_ta*
e.g. tag = test_ta*
e.g. tag != test_ta*
Objects not marked with the tag from the condition.
Nested tags are not taken into account!
Changes introduced with this PR
Are you the owner of the code you are sending in, or do you have permission of the owner?
y