Merge pull request #25999 from kamipo/remove_sanitize_conditions

Remove `sanitize_conditions` and use `sanitize_sql` instead of `sanitize_conditions`
This commit is contained in:
Rafael França 2016-08-18 22:57:27 -03:00 committed by GitHub
commit c2af081c4f
3 changed files with 8 additions and 4 deletions

@ -1,3 +1,7 @@
* Deprecate `sanitize_conditions`. Use `sanitize_sql` instead.
*Ryuta Kamizono*
* Doing count on relations that contain LEFT OUTER JOIN Arel node no longer
force a DISTINCT. This solves issues when using count after a left_joins.

@ -62,8 +62,7 @@ def find_by_sql(sql, binds = [], preparable: nil)
#
# * +sql+ - An SQL statement which should return a count query from the database, see the example above.
def count_by_sql(sql)
sql = sanitize_conditions(sql)
connection.select_value(sql, "#{name} Count").to_i
connection.select_value(sanitize_sql(sql), "#{name} Count").to_i
end
end
end

@ -29,8 +29,9 @@ def sanitize_sql_for_conditions(condition)
else condition
end
end
alias_method :sanitize_sql, :sanitize_sql_for_conditions
alias_method :sanitize_conditions, :sanitize_sql
alias :sanitize_sql :sanitize_sql_for_conditions
alias :sanitize_conditions :sanitize_sql
deprecate sanitize_conditions: :sanitize_sql
# Accepts an array, hash, or string of SQL conditions and sanitizes
# them into a valid SQL fragment for a SET clause.