aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-12-05 14:15:50 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-12-05 14:15:50 -0800
commit988061ddb802e6803d19de954762753f14551c56 (patch)
tree944f5f89444e74d3bd2032da492f09cc1f0991d3 /activerecord
parent38185f670e2dd4bb1ec9bf6e3397d7ad9da630ee (diff)
parent73a331c2acfce971aa2dda8e72af5edc6867e344 (diff)
downloadrails-988061ddb802e6803d19de954762753f14551c56.tar.gz
rails-988061ddb802e6803d19de954762753f14551c56.tar.bz2
rails-988061ddb802e6803d19de954762753f14551c56.zip
Merge pull request #3867 from jadeforrest/master
Increase performance for table_exists?
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index ce4c5a1383..7ff3b755fd 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -23,7 +23,12 @@ module ActiveRecord
# === Example
# table_exists?(:developers)
def table_exists?(table_name)
- tables.include?(table_name.to_s)
+ begin
+ select_value("SELECT 1 FROM #{table_name.to_s} where 1=0")
+ true
+ rescue
+ false
+ end
end
# Returns an array of indexes for the given table.