Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-08-08 03:16:38 +0300
committerMichael Kozono <mkozono@gmail.com>2017-08-08 20:30:07 +0300
commitf4ecbf16231de596eb9af0ef469087b90be5b83d (patch)
tree40cf5d77ca22885c73f2736cde5a0e9f75c9ad97 /app
parent4f71c557be3abfb855e8489fad2c8f1614d9fb8b (diff)
Remove unnecessary work for MySQL
Diffstat (limited to 'app')
-rw-r--r--app/models/redirect_route.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/redirect_route.rb b/app/models/redirect_route.rb
index a034aacb23c..090fbd61e6f 100644
--- a/app/models/redirect_route.rb
+++ b/app/models/redirect_route.rb
@@ -8,5 +8,13 @@ class RedirectRoute < ActiveRecord::Base
presence: true,
uniqueness: { case_sensitive: false }
- scope :matching_path_and_descendants, -> (path) { where('LOWER(redirect_routes.path) = LOWER(?) OR LOWER(redirect_routes.path) LIKE LOWER(?)', path, "#{sanitize_sql_like(path)}/%") }
+ scope :matching_path_and_descendants, -> (path) do
+ wheres = if Gitlab::Database.postgresql?
+ 'LOWER(redirect_routes.path) = LOWER(?) OR LOWER(redirect_routes.path) LIKE LOWER(?)'
+ else
+ 'redirect_routes.path = ? OR redirect_routes.path LIKE ?'
+ end
+
+ where(wheres, path, "#{sanitize_sql_like(path)}/%")
+ end
end