Remove repeated routes.path check for postgresql database
What does this MR do?
Remove repeated routes.path comparison for postgresql database. Before:
SELECT "projects".*
FROM "projects"
INNER JOIN "routes" ON "routes"."source_id" = "projects"."id"
AND "routes"."source_type" = 'Project'
WHERE "projects"."pending_delete" = 'f'
AND (((routes.path = 'gitlab-org/gitlab-ci')
OR (LOWER(routes.path) = LOWER('gitlab-org/gitlab-ci'))))
ORDER BY (CASE
WHEN routes.path = 'gitlab-org/gitlab-ci' THEN 0
ELSE 1
END)
LIMIT 1
After:
SELECT "projects".*
FROM "projects"
INNER JOIN "routes" ON "routes"."source_id" = "projects"."id"
AND "routes"."source_type" = 'Project'
WHERE "projects"."pending_delete" = 'f'
AND ((LOWER(routes.path) = LOWER('gitlab-org/gitlab-ci')))
ORDER BY (CASE
WHEN routes.path = 'gitlab-org/gitlab-ci' THEN 0
ELSE 1
END)
LIMIT 1
Are there points in the code the reviewer needs to double check?
- I didn't use
CaseSensitivity#iwhere
because it'll return a result.
where_full_path_in
could be simplified to something like
if paths.empty?
none
else
if cast_lower
joins(:route).where(routes[:path].lower.in(paths.map(&:downcase)))
else
joins(:route).where(routes[:path].in(paths))
end
end
I find the above implementation simpler/easier to read, but that's just my opinion.
Why was this MR needed?
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together