From 323b7585e106ca9ca26db5a886801239c725a95a Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Tue, 3 May 2011 21:14:27 +0200 Subject: added the mysql schema test to mysql2 adapter, and fixed the corresponding failures --- .../connection_adapters/mysql2_adapter.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') 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 -- cgit v1.2.3