diff options
author | Comron Sattari <comron.sattari@appfolio.com> | 2010-05-02 13:09:22 +0200 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-05-16 17:40:40 -0700 |
commit | e1a340a91d4ee0bbbe8ce1a74b88b3f7e80c1197 (patch) | |
tree | 80962bde5317505cff26d0c99c46160d258c07a4 /activerecord | |
parent | 6b4e0cc526f55b5532cf99292c94f0a4db53b16f (diff) | |
download | rails-e1a340a91d4ee0bbbe8ce1a74b88b3f7e80c1197.tar.gz rails-e1a340a91d4ee0bbbe8ce1a74b88b3f7e80c1197.tar.bz2 rails-e1a340a91d4ee0bbbe8ce1a74b88b3f7e80c1197.zip |
cache connection when quoting
[#3642 state:committed]
Signed-off-by: Marius Nuennerich <marius@nuenneri.ch>
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index c02af328c1..37675d8ab1 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1362,7 +1362,8 @@ module ActiveRecord #:nodoc: 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 @@ module ActiveRecord #: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 |