Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
12633b46
Commit
12633b46
authored
Aug 29, 2017
by
Hiroyuki Sato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor
parent
87b51c59
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
8 deletions
+4
-8
lib/gitlab/sql/pattern.rb
lib/gitlab/sql/pattern.rb
+3
-7
spec/lib/gitlab/sql/pattern_spec.rb
spec/lib/gitlab/sql/pattern_spec.rb
+1
-1
No files found.
lib/gitlab/sql/pattern.rb
View file @
12633b46
...
...
@@ -7,17 +7,13 @@ module Gitlab
class_methods
do
def
to_pattern
(
query
)
if
exact_matching?
(
query
)
sanitize_sql_like
(
query
)
else
if
partial_matching?
(
query
)
"%
#{
sanitize_sql_like
(
query
)
}
%"
else
sanitize_sql_like
(
query
)
end
end
def
exact_matching?
(
query
)
query
.
length
<
MIN_CHARS_FOR_PARTIAL_MATCHING
end
def
partial_matching?
(
query
)
query
.
length
>=
MIN_CHARS_FOR_PARTIAL_MATCHING
end
...
...
spec/lib/gitlab/sql/pattern_spec.rb
View file @
12633b46
require
'spec_helper'
describe
Gitlab
::
SQL
::
Pattern
do
describe
'
#
to_pattern'
do
describe
'
.
to_pattern'
do
subject
(
:to_pattern
)
{
User
.
to_pattern
(
query
)
}
context
'when a query is shorter than 3 chars'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment