engine: Support for 'AND' and 'not equal' expressions for objects with multiple tags #1008
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