Rails4: replace deprecated #connection from Query model
DEPRECATION WARNING: #connection is deprecated in favour of accessing it via the class. git-svn-id: http://svn.redmine.org/redmine/trunk@12720 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f5c5393d09
commit
dff2721fbe
|
@ -640,7 +640,7 @@ class Query < ActiveRecord::Base
|
||||||
sql = "#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}"
|
sql = "#{db_table}.#{db_field} BETWEEN #{value.first.to_f - 1e-5} AND #{value.first.to_f + 1e-5}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
|
sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{ActiveRecord::Base.connection.quote_string(val)}'"}.join(",") + ")"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# IN an empty set
|
# IN an empty set
|
||||||
|
@ -648,7 +648,7 @@ class Query < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
when "!"
|
when "!"
|
||||||
if value.any?
|
if value.any?
|
||||||
sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))"
|
sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| "'#{ActiveRecord::Base.connection.quote_string(val)}'"}.join(",") + "))"
|
||||||
else
|
else
|
||||||
# NOT IN an empty set
|
# NOT IN an empty set
|
||||||
sql = "1=1"
|
sql = "1=1"
|
||||||
|
@ -690,9 +690,9 @@ class Query < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
when "o"
|
when "o"
|
||||||
sql = "#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_false})" if field == "status_id"
|
sql = "#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{ActiveRecord::Base.connection.quoted_false})" if field == "status_id"
|
||||||
when "c"
|
when "c"
|
||||||
sql = "#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{connection.quoted_true})" if field == "status_id"
|
sql = "#{queried_table_name}.status_id IN (SELECT id FROM #{IssueStatus.table_name} WHERE is_closed=#{ActiveRecord::Base.connection.quoted_true})" if field == "status_id"
|
||||||
when "><t-"
|
when "><t-"
|
||||||
# between today - n days and today
|
# between today - n days and today
|
||||||
sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)
|
sql = relative_date_clause(db_table, db_field, - value.first.to_i, 0)
|
||||||
|
@ -754,9 +754,9 @@ class Query < ActiveRecord::Base
|
||||||
date = Date.today
|
date = Date.today
|
||||||
sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)
|
sql = date_clause(db_table, db_field, date.beginning_of_year, date.end_of_year)
|
||||||
when "~"
|
when "~"
|
||||||
sql = "LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'"
|
sql = "LOWER(#{db_table}.#{db_field}) LIKE '%#{ActiveRecord::Base.connection.quote_string(value.first.to_s.downcase)}%'"
|
||||||
when "!~"
|
when "!~"
|
||||||
sql = "LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'"
|
sql = "LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{ActiveRecord::Base.connection.quote_string(value.first.to_s.downcase)}%'"
|
||||||
else
|
else
|
||||||
raise "Unknown query operator #{operator}"
|
raise "Unknown query operator #{operator}"
|
||||||
end
|
end
|
||||||
|
@ -819,7 +819,7 @@ class Query < ActiveRecord::Base
|
||||||
if self.class.default_timezone == :utc
|
if self.class.default_timezone == :utc
|
||||||
from = from.utc
|
from = from.utc
|
||||||
end
|
end
|
||||||
s << ("#{table}.#{field} > '%s'" % [connection.quoted_date(from)])
|
s << ("#{table}.#{field} > '%s'" % [ActiveRecord::Base.connection.quoted_date(from)])
|
||||||
end
|
end
|
||||||
if to
|
if to
|
||||||
if to.is_a?(Date)
|
if to.is_a?(Date)
|
||||||
|
@ -828,7 +828,7 @@ class Query < ActiveRecord::Base
|
||||||
if self.class.default_timezone == :utc
|
if self.class.default_timezone == :utc
|
||||||
to = to.utc
|
to = to.utc
|
||||||
end
|
end
|
||||||
s << ("#{table}.#{field} <= '%s'" % [connection.quoted_date(to)])
|
s << ("#{table}.#{field} <= '%s'" % [ActiveRecord::Base.connection.quoted_date(to)])
|
||||||
end
|
end
|
||||||
s.join(' AND ')
|
s.join(' AND ')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue