Skip to content

Commit

Permalink
Remove deprecated name argument from #tables
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelfranca committed Dec 29, 2016
1 parent e646bad commit d5be101
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 30 deletions.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Remove deprecated `name` argument from `#tables`.

*Rafael Mendonça França*

* Remove deprecated support to passing a column to `#quote`.

*Rafael Mendonça França*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def data_source_exists?(name)
end

# Returns an array of table names defined in the database.
def tables(name = nil)
def tables
raise NotImplementedError, "#tables is not implemented"
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,13 @@ def collation
show_variable "collation_database"
end

def tables(name = nil) # :nodoc:
def tables # :nodoc:
ActiveSupport::Deprecation.warn(<<-MSG.squish)
#tables currently returns both tables and views.
This behavior is deprecated and will be changed with Rails 5.1 to only return tables.
Use #data_sources instead.
MSG

if name
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Passing arguments to #tables is deprecated without replacement.
MSG
end

data_sources
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,7 @@ def drop_database(name) #:nodoc:
end

# Returns the list of all tables in the schema search path.
def tables(name = nil)
if name
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Passing arguments to #tables is deprecated without replacement.
MSG
end

def tables
select_values("SELECT tablename FROM pg_tables WHERE schemaname = ANY(current_schemas(false))", "SCHEMA")
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,13 @@ def exec_rollback_db_transaction #:nodoc:

# SCHEMA STATEMENTS ========================================

def tables(name = nil) # :nodoc:
def tables # :nodoc:
ActiveSupport::Deprecation.warn(<<-MSG.squish)
#tables currently returns both tables and views.
This behavior is deprecated and will be changed with Rails 5.1 to only return tables.
Use #data_sources instead.
MSG

if name
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Passing arguments to #tables is deprecated without replacement.
MSG
end

data_sources
end

Expand Down
4 changes: 0 additions & 4 deletions activerecord/test/cases/adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,6 @@ def test_tables_returning_both_tables_and_views_is_deprecated
assert_deprecated { @connection.tables }
end
end

def test_passing_arguments_to_tables_is_deprecated
assert_deprecated { @connection.tables(:books) }
end
end

class AdapterTestWithoutTransaction < ActiveRecord::TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_reset_with_transaction
end

def test_tables_logs_name
ActiveSupport::Deprecation.silence { @connection.tables("hello") }
@connection.tables
assert_equal "SCHEMA", @subscriber.logged[0][1]
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,7 @@ def test_tables_logs_name
WHERE type IN ('table','view') AND name <> 'sqlite_sequence'
SQL
assert_logged [[sql.squish, "SCHEMA", []]] do
ActiveSupport::Deprecation.silence do
@conn.tables("hello")
end
@conn.tables
end
end

Expand Down

0 comments on commit d5be101

Please sign in to comment.