Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cache connection when quoting

[#3642 state:committed]

Signed-off-by: Marius Nuennerich <marius@nuenneri.ch>
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
commit e1a340a91d4ee0bbbe8ce1a74b88b3f7e80c1197 1 parent 6b4e0cc
Comron Sattari authored jeremy committed
Showing with 6 additions and 5 deletions.
  1. +6 −5 activerecord/lib/active_record/base.rb
View
11 activerecord/lib/active_record/base.rb
@@ -1362,7 +1362,8 @@ def sanitize_sql_array(ary)
def replace_bind_variables(statement, values) #:nodoc:
raise_if_bind_arity_mismatch(statement, statement.count('?'), values.size)
bound = values.dup
- statement.gsub('?') { quote_bound_value(bound.shift) }
+ c = connection
+ statement.gsub('?') { quote_bound_value(bound.shift, c) }
end
def replace_named_bind_variables(statement, bind_vars) #:nodoc:
@@ -1394,15 +1395,15 @@ def expand_range_bind_variables(bind_vars) #:nodoc:
expanded
end
- def quote_bound_value(value) #:nodoc:
+ def quote_bound_value(value, c = connection) #:nodoc:
if value.respond_to?(:map) && !value.acts_like?(:string)
if value.respond_to?(:empty?) && value.empty?
- connection.quote(nil)
+ c.quote(nil)
else
- value.map { |v| connection.quote(v) }.join(',')
+ value.map { |v| c.quote(v) }.join(',')
end
else
- connection.quote(value)
+ c.quote(value)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.