aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/table.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-09-15 14:36:15 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-09-15 14:36:15 -0700
commite460aa96ae9bd5f1a24d798b2d22984a54810c70 (patch)
treefeecb3aa95be57016eb84cc5cdfb904f51df7a63 /lib/arel/table.rb
parent62e36ebba05778b76b97386d5771d3aafd5c4782 (diff)
downloadrails-e460aa96ae9bd5f1a24d798b2d22984a54810c70.tar.gz
rails-e460aa96ae9bd5f1a24d798b2d22984a54810c70.tar.bz2
rails-e460aa96ae9bd5f1a24d798b2d22984a54810c70.zip
Table#[] returns nil when table does not exist
Diffstat (limited to 'lib/arel/table.rb')
-rw-r--r--lib/arel/table.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/arel/table.rb b/lib/arel/table.rb
index 06bbe7b99e..c381613515 100644
--- a/lib/arel/table.rb
+++ b/lib/arel/table.rb
@@ -88,6 +88,8 @@ module Arel
end
def [] name
+ return nil unless @engine.connection.table_exists?(@name)
+
name = name.to_sym
columns.find { |column| column.name == name }
end