diff options
author | Josh Kalderimis <josh.kalderimis@gmail.com> | 2011-05-03 21:14:27 +0200 |
---|---|---|
committer | Josh Kalderimis <josh.kalderimis@gmail.com> | 2011-05-03 21:15:10 +0200 |
commit | 323b7585e106ca9ca26db5a886801239c725a95a (patch) | |
tree | 5fd9f04aa6061ee6c6a3a91f5fb1b6c4c111430c /activerecord/lib/active_record | |
parent | d54ce7129c9a5983b5f0bfd05b35b52229211014 (diff) | |
download | rails-323b7585e106ca9ca26db5a886801239c725a95a.tar.gz rails-323b7585e106ca9ca26db5a886801239c725a95a.tar.bz2 rails-323b7585e106ca9ca26db5a886801239c725a95a.zip |
added the mysql schema test to mysql2 adapter, and fixed the corresponding failures
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb index 98a8dd6453..42eeacc173 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -410,12 +410,27 @@ module ActiveRecord show_variable 'collation_database' end - def tables(name = nil) - execute("SHOW TABLES", 'SCHEMA').collect do |field| + def tables(name = nil, database = nil) #:nodoc: + sql = ["SHOW TABLES", database].compact.join(' IN ') + execute(sql, 'SCHEMA').collect do |field| field.first end end + def table_exists?(name) + return true if super + + name = name.to_s + schema, table = name.split('.', 2) + + unless table # A table was provided without a schema + table = schema + schema = nil + end + + tables(nil, schema).include? table + end + def drop_table(table_name, options = {}) super(table_name, options) end |