diff --git a/lib/arel/engines/sql/relations/table.rb b/lib/arel/engines/sql/relations/table.rb index f56fd7d8..82668970 100644 --- a/lib/arel/engines/sql/relations/table.rb +++ b/lib/arel/engines/sql/relations/table.rb @@ -13,6 +13,8 @@ def tables= e; @@tables = e; end end attr_reader :name, :engine, :table_alias, :options, :christener + attr_reader :table_exists + alias :table_exists? :table_exists def initialize(name, options = {}) @name = name.to_s @@ -45,6 +47,8 @@ def initialize(name, options = {}) end @@tables ||= engine.connection.tables + @table_exists = @@tables.include?(name) || + @engine.connection.table_exists?(name) end end @@ -52,10 +56,6 @@ def as(table_alias) Table.new(name, options.merge(:as => table_alias)) end - def table_exists? - @table_exists ||= @@tables.include?(name) || engine.connection.table_exists?(name) - end - def attributes return @attributes if defined?(@attributes) if table_exists?