diff options
author | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2010-03-01 14:19:25 +0200 |
---|---|---|
committer | Raimonds Simanovskis <raimonds.simanovskis@gmail.com> | 2010-03-01 14:19:25 +0200 |
commit | 07dcfd4ea7c052063e912ab479f64da78848a66e (patch) | |
tree | e6d724266baa51001ae98897f0bb08b6e6384a98 /lib/arel/engines/sql/relations/relation.rb | |
parent | 19c4de17ed40b323b5d771b81e28fe7b7490efc2 (diff) | |
download | rails-07dcfd4ea7c052063e912ab479f64da78848a66e.tar.gz rails-07dcfd4ea7c052063e912ab479f64da78848a66e.tar.bz2 rails-07dcfd4ea7c052063e912ab479f64da78848a66e.zip |
cache primary key per engine connection, updated gemspec file
Diffstat (limited to 'lib/arel/engines/sql/relations/relation.rb')
-rw-r--r-- | lib/arel/engines/sql/relations/relation.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/arel/engines/sql/relations/relation.rb b/lib/arel/engines/sql/relations/relation.rb index 4249cf9b0d..5e8fc2e83e 100644 --- a/lib/arel/engines/sql/relations/relation.rb +++ b/lib/arel/engines/sql/relations/relation.rb @@ -1,6 +1,6 @@ module Arel class Relation - @@tables_primary_keys = {} + @@connection_tables_primary_keys = {} def compiler @compiler ||= begin @@ -23,10 +23,12 @@ module Arel end def primary_key - if @@tables_primary_keys.has_key?(table.name) - @@tables_primary_keys[table.name] + connection_id = engine.connection.object_id + if @@connection_tables_primary_keys[connection_id] && @@connection_tables_primary_keys[connection_id].has_key?(table.name) + @@connection_tables_primary_keys[connection_id][table.name] else - @@tables_primary_keys[table.name] = engine.primary_key(table.name) + @@connection_tables_primary_keys[connection_id] ||= {} + @@connection_tables_primary_keys[connection_id][table.name] = engine.connection.primary_key(table.name) end end |