From: Go MAEDA Date: Tue, 14 May 2024 08:04:04 +0000 (+0000) Subject: Explicitly reference table name in Project#like scope to avoid ambiguity (#40691). X-Git-Tag: 6.0.0~336 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=250414c3539ecd31bbad0b6ae4f4cf94b2b1864e;p=redmine.git 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 --- diff --git a/app/models/project.rb b/app/models/project.rb index abac2a1f0..2b3280651 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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)}