aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engines
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/engines')
-rw-r--r--lib/arel/engines/sql/relations/relation.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/arel/engines/sql/relations/relation.rb b/lib/arel/engines/sql/relations/relation.rb
index 52b91c71ea..4249cf9b0d 100644
--- a/lib/arel/engines/sql/relations/relation.rb
+++ b/lib/arel/engines/sql/relations/relation.rb
@@ -1,5 +1,6 @@
module Arel
class Relation
+ @@tables_primary_keys = {}
def compiler
@compiler ||= begin
@@ -22,10 +23,10 @@ module Arel
end
def primary_key
- @primary_key ||= begin
- table.name.classify.constantize.primary_key
- rescue NameError
- nil
+ if @@tables_primary_keys.has_key?(table.name)
+ @@tables_primary_keys[table.name]
+ else
+ @@tables_primary_keys[table.name] = engine.primary_key(table.name)
end
end