diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-15 18:43:41 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-26 13:44:10 -0700 |
commit | 1b4e0b654210d024989dd4b46311807e2c823bdb (patch) | |
tree | 3441d3d89303b0ad408cc0a489b7a2e28b090762 /activerecord | |
parent | 43bbb25ddd413acc27998fe25be8f086585a7a2e (diff) | |
download | rails-1b4e0b654210d024989dd4b46311807e2c823bdb.tar.gz rails-1b4e0b654210d024989dd4b46311807e2c823bdb.tar.bz2 rails-1b4e0b654210d024989dd4b46311807e2c823bdb.zip |
prepare the statement before we cache the key
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 6 |
1 files changed, 4 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 71adfe8d8c..3bd5acb23d 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -220,7 +220,7 @@ module ActiveRecord @local_tz = nil @table_alias_length = nil @postgresql_version = nil - @statements = Hash.new { |h,k| h[k] = "a#{h.length + 1}" } + @statements = {} connect @local_tz = execute('SHOW TIME ZONE').first["TimeZone"] @@ -530,7 +530,9 @@ module ActiveRecord def async_exec(sql, name, binds) log(sql, name) do unless @statements.key? sql - @connection.prepare @statements[sql], sql + nextkey = "a#{@statements.length + 1}" + @connection.prepare nextkey, sql + @statements[sql] = nextkey end key = @statements[sql] |