summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-03-12 08:13:21 +0000
committerSean McGivern <sean@gitlab.com>2019-03-13 10:54:43 +0000
commiteba5672077f5d7956fc8f7db583136b3ccb451b5 (patch)
tree59dacd4c67a6909e5abdbc364bcd7c5e0ebfba2b /lib
parentf859b0e1e7f257a962866c98eca430c1338b7dba (diff)
downloadgitlab-ce-eba5672077f5d7956fc8f7db583136b3ccb451b5.tar.gz
Allow filtering labels by a single character
When we use Gitlab::SQL::Pattern, this typically relates to a trigram index. As the 'tri' indicates, we need at least three characters to be able to use that index. Labels don't have a trigram index, because we never allow you to search for them globally: it's always in the context of a project or a group. In that context, it's just as fast to search for a single character (in general) because there is already a pretty specific index being used.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/sql/pattern.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/gitlab/sql/pattern.rb b/lib/gitlab/sql/pattern.rb
index 07d0acdbae9..b698391c8bd 100644
--- a/lib/gitlab/sql/pattern.rb
+++ b/lib/gitlab/sql/pattern.rb
@@ -23,8 +23,12 @@ module Gitlab
end
end
+ def min_chars_for_partial_matching
+ MIN_CHARS_FOR_PARTIAL_MATCHING
+ end
+
def partial_matching?(query)
- query.length >= MIN_CHARS_FOR_PARTIAL_MATCHING
+ query.length >= min_chars_for_partial_matching
end
# column - The column name to search in.