Fixes #38131 - Use #include? instead of Regexp substring match #940
+40
−12
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.
This PR only replaces
=~
withinclude?
leaving the current behavior as is.We could go extra mile with this in terms of optimizing:
This will take only 100 items from DB which match the param. There are some downsides though:
to_s
on each. Depending on exact implementation it always will return a string with at least something to compare with the param. This approach uses DB search, so we can compare only string column and if they are present at all. This can be workarounded, but will require more changes. Not sure if it's worth for some entities such asAudit
orTemplateInvocation
, whereAudit.any.to_s
produces basically unusable string andTemplateInvocation.any.to_s
produces just a string with id of the object, which I don't find useful in context of template inputs. See screenshots:Before:
After:
It'll fail internally with error, since it tries
~
operator on an integer column.