1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-31 11:37:14 +00:00

Explicitly reference table name in Project#like scope to avoid ambiguity (#40691).

Patch by Vincent Robert (@Nanego).


git-svn-id: https://svn.redmine.org/redmine/trunk@22830 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA 2024-05-14 08:04:04 +00:00
parent 3761510af8
commit 250414c353

View File

@ -110,7 +110,7 @@ class Project < ApplicationRecord
scope :like, (lambda do |arg|
if arg.present?
pattern = "%#{sanitize_sql_like arg.to_s.strip}%"
where("LOWER(identifier) LIKE LOWER(:p) ESCAPE :s OR LOWER(name) LIKE LOWER(:p) ESCAPE :s", :p => pattern, :s => '\\')
where("LOWER(#{Project.table_name}.identifier) LIKE LOWER(:p) ESCAPE :s OR LOWER(#{Project.table_name}.name) LIKE LOWER(:p) ESCAPE :s", :p => pattern, :s => '\\')
end
end)
scope :sorted, lambda {order(:lft)}