aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-30 14:41:26 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-30 14:41:26 -0700
commit19c5a95f1093653d2628dfb2f53637b0425dbba4 (patch)
tree1b68af987a39bbdbbd3a4f07bb4ade0cfb86ae84
parent165a312fb3c3ad0e55478b99fa1851b5ee8c56a0 (diff)
downloadrails-19c5a95f1093653d2628dfb2f53637b0425dbba4.tar.gz
rails-19c5a95f1093653d2628dfb2f53637b0425dbba4.tar.bz2
rails-19c5a95f1093653d2628dfb2f53637b0425dbba4.zip
caching existence of a table
-rw-r--r--lib/arel/engines/sql/relations/table.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/arel/engines/sql/relations/table.rb b/lib/arel/engines/sql/relations/table.rb
index f56fd7d813..8266897098 100644
--- a/lib/arel/engines/sql/relations/table.rb
+++ b/lib/arel/engines/sql/relations/table.rb
@@ -13,6 +13,8 @@ module Arel
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 @@ module Arel
end
@@tables ||= engine.connection.tables
+ @table_exists = @@tables.include?(name) ||
+ @engine.connection.table_exists?(name)
end
end
@@ -52,10 +56,6 @@ module Arel
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?