Actions
Patch #40691
closedRemove ambiguity in queries utilizing a Project scope
Description
Hello
Please consider this patch which removes ambiguity in queries utilizing the scope "like" in the Project model.
It just adds the table name before the attribute.
Thank you
diff --git a/app/models/project.rb b/app/models/project.rb
index 9f9656976..9177a8b15 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -109,7 +109,7 @@ class Project < ActiveRecord::Base
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)}
Files
Actions