Skip to content

Commit

Permalink
Avoid repeated calls to Base#connection. Closes #11111 [adymo]
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8871 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
NZKoz committed Feb 14, 2008
1 parent 838b024 commit c75abf0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions activerecord/lib/active_record/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2417,9 +2417,10 @@ def attributes_protected_by_default
# an SQL statement.
def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true)
quoted = {}
connection = self.class.connection
@attributes.each_pair do |name, value|
if column = column_for_attribute(name)
quoted[name] = quote_value(read_attribute(name), column) unless !include_primary_key && column.primary
quoted[name] = connection.quote(read_attribute(name), column) unless !include_primary_key && column.primary
end
end
include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)
Expand Down Expand Up @@ -2529,8 +2530,9 @@ def comma_pair_list(hash)
end

def quoted_column_names(attributes = attributes_with_quotes)
connection = self.class.connection
attributes.keys.collect do |column_name|
self.class.connection.quote_column_name(column_name)
connection.quote_column_name(column_name)
end
end

Expand Down

0 comments on commit c75abf0

Please sign in to comment.