diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2015-10-21 12:58:32 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2015-10-22 13:16:35 +0900 |
commit | edfb738b9c08dbe5ccfd5febf9361d4d3452334a (patch) | |
tree | 15faee4ade3d0f2d89104d2cc7cc192b485d36ff /activerecord/lib | |
parent | d8b076c90efac796e8664c6eada8d08afac4bea3 (diff) | |
download | rails-edfb738b9c08dbe5ccfd5febf9361d4d3452334a.tar.gz rails-edfb738b9c08dbe5ccfd5febf9361d4d3452334a.tar.bz2 rails-edfb738b9c08dbe5ccfd5febf9361d4d3452334a.zip |
Remove `#tables` extra args again
This issue was resolved by #21687 already. But re-add args by #18856.
`#tables` extra args was only using by `#table_exists?`. This is for
internal API. This commit will remove these extra args again.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 11 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb | 20 |
2 files changed, 11 insertions, 20 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 59137fb842..251acf1c83 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -482,16 +482,11 @@ module ActiveRecord show_variable 'collation_database' end - def tables(name = nil, database = nil, like = nil) #:nodoc: - database ||= current_database - + def tables(name = nil) # :nodoc: sql = "SELECT table_name FROM information_schema.tables " - sql << "WHERE table_schema = #{quote(database)}" - sql << " AND table_name = #{quote(like)}" if like + sql << "WHERE table_schema = #{quote(@config[:database])}" - execute_and_free(sql, 'SCHEMA') do |result| - result.collect(&:first) - end + select_values(sql, 'SCHEMA') end alias data_sources tables diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 5fb34dbfac..9028c1fcb9 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -311,22 +311,18 @@ module ActiveRecord # SCHEMA STATEMENTS ======================================== - def tables(name = nil, table_name = nil) #:nodoc: - sql = <<-SQL - SELECT name - FROM sqlite_master - WHERE (type = 'table' OR type = 'view') AND NOT name = 'sqlite_sequence' - SQL - sql << " AND name = #{quote_table_name(table_name)}" if table_name - - exec_query(sql, 'SCHEMA').map do |row| - row['name'] - end + def tables(name = nil) # :nodoc: + select_values("SELECT name FROM sqlite_master WHERE type IN ('table','view') AND name <> 'sqlite_sequence'", 'SCHEMA') end alias data_sources tables def table_exists?(table_name) - table_name && tables(nil, table_name).any? + return false unless table_name.present? + + sql = "SELECT name FROM sqlite_master WHERE type IN ('table','view') AND name <> 'sqlite_sequence'" + sql << " AND name = #{quote(table_name)}" + + select_values(sql, 'SCHEMA').any? end alias data_source_exists? table_exists? |