Skip to content
This repository
Browse code

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 1 changed file with 6 additions and 5 deletions. Show diff stats Hide diff stats

  1. +6 5 activerecord/lib/active_record/base.rb
11 activerecord/lib/active_record/base.rb
@@ -1362,7 +1362,8 @@ def sanitize_sql_array(ary)
1362 1362 def replace_bind_variables(statement, values) #:nodoc:
1363 1363 raise_if_bind_arity_mismatch(statement, statement.count('?'), values.size)
1364 1364 bound = values.dup
1365   - statement.gsub('?') { quote_bound_value(bound.shift) }
  1365 + c = connection
  1366 + statement.gsub('?') { quote_bound_value(bound.shift, c) }
1366 1367 end
1367 1368
1368 1369 def replace_named_bind_variables(statement, bind_vars) #:nodoc:
@@ -1394,15 +1395,15 @@ def expand_range_bind_variables(bind_vars) #:nodoc:
1394 1395 expanded
1395 1396 end
1396 1397
1397   - def quote_bound_value(value) #:nodoc:
  1398 + def quote_bound_value(value, c = connection) #:nodoc:
1398 1399 if value.respond_to?(:map) && !value.acts_like?(:string)
1399 1400 if value.respond_to?(:empty?) && value.empty?
1400   - connection.quote(nil)
  1401 + c.quote(nil)
1401 1402 else
1402   - value.map { |v| connection.quote(v) }.join(',')
  1403 + value.map { |v| c.quote(v) }.join(',')
1403 1404 end
1404 1405 else
1405   - connection.quote(value)
  1406 + c.quote(value)
1406 1407 end
1407 1408 end
1408 1409

0 comments on commit e1a340a

Please sign in to comment.
Something went wrong with that request. Please try again.