diff options
Diffstat (limited to 'lib/arel/table.rb')
-rw-r--r-- | lib/arel/table.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/arel/table.rb b/lib/arel/table.rb index 1519efa63b..06bbe7b99e 100644 --- a/lib/arel/table.rb +++ b/lib/arel/table.rb @@ -14,6 +14,7 @@ module Arel @columns = nil @aliases = [] @table_alias = nil + @primary_key = nil # Sometime AR sends an :as parameter to table, to let the table know that # it is an Alias. We may want to override new, and return a TableAlias @@ -21,6 +22,10 @@ module Arel @table_alias = engine[:as] if Hash === engine end + def primary_key + @primary_key ||= self[@engine.connection.primary_key(name)] + end + def alias Nodes::TableAlias.new("#{name}_2", self).tap do |node| @aliases << node |