aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorEugene Pimenov <libc@mac.com>2009-04-23 13:45:12 +0400
committerMichael Koziarski <michael@koziarski.com>2009-06-09 20:12:01 +1200
commit74c1249d0727e6375529e4bb5b2e2ac78f4a91dc (patch)
tree5912d1ea691667813471ca17982354a6bc767bb5 /activerecord
parent99803b7cdba13345d267127e14809fc389a0e0c2 (diff)
downloadrails-74c1249d0727e6375529e4bb5b2e2ac78f4a91dc.tar.gz
rails-74c1249d0727e6375529e4bb5b2e2ac78f4a91dc.tar.bz2
rails-74c1249d0727e6375529e4bb5b2e2ac78f4a91dc.zip
PostgreSQL adapter should call thread safe quote_string function
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 002696d2c4..18b499904e 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -288,7 +288,13 @@ module ActiveRecord
# Escapes binary strings for bytea input to the database.
def escape_bytea(value)
- if PGconn.respond_to?(:escape_bytea)
+ if @connection.respond_to?(:escape_bytea)
+ self.class.instance_eval do
+ define_method(:escape_bytea) do |value|
+ @connection.escape_bytea(value) if value
+ end
+ end
+ elsif PGconn.respond_to?(:escape_bytea)
self.class.instance_eval do
define_method(:escape_bytea) do |value|
PGconn.escape_bytea(value) if value
@@ -377,7 +383,13 @@ module ActiveRecord
# Quotes strings for use in SQL input in the postgres driver for better performance.
def quote_string(s) #:nodoc:
- if PGconn.respond_to?(:escape)
+ if @connection.respond_to?(:escape)
+ self.class.instance_eval do
+ define_method(:quote_string) do |s|
+ @connection.escape(s)
+ end
+ end
+ elsif PGconn.respond_to?(:escape)
self.class.instance_eval do
define_method(:quote_string) do |s|
PGconn.escape(s)