mirror of
https://github.com/github/rails.git
synced 2026-02-03 10:45:01 -05:00
Avoid Base#attributes when saving / creating records. Closes #10978 [adymo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8770 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -2426,11 +2426,11 @@ module ActiveRecord #:nodoc:
|
||||
# Returns a copy of the attributes hash where all the values have been safely quoted for use in
|
||||
# an SQL statement.
|
||||
def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true)
|
||||
quoted = attributes.inject({}) do |result, (name, value)|
|
||||
quoted = {}
|
||||
@attributes.each_pair do |name, value|
|
||||
if column = column_for_attribute(name)
|
||||
result[name] = quote_value(value, column) unless !include_primary_key && column.primary
|
||||
quoted[name] = quote_value(read_attribute(name), column) unless !include_primary_key && column.primary
|
||||
end
|
||||
result
|
||||
end
|
||||
include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user