Skip to content

Commit 18e4f20

Browse files
committed
[Rails5] Conform to table_exists decprecations.
1 parent dc44fa2 commit 18e4f20

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/active_record/connection_adapters/sqlserver/schema_statements.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ def tables(table_type = 'BASE TABLE')
1111
select_values "SELECT #{lowercase_schema_reflection_sql('TABLE_NAME')} FROM INFORMATION_SCHEMA.TABLES #{"WHERE TABLE_TYPE = '#{table_type}'" if table_type} ORDER BY TABLE_NAME", 'SCHEMA'
1212
end
1313

14+
def table_exists?(table_name)
15+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
16+
#table_exists? currently checks both tables and views.
17+
This behavior is deprecated and will be changed with Rails 5.1 to only check tables.
18+
Use #data_source_exists? instead.
19+
MSG
20+
data_source_exists?(table_name)
21+
end
22+
1423
def data_source_exists?(table_name)
1524
return false if table_name.blank?
1625
unquoted_table_name = SQLServer::Utils.extract_identifiers(table_name).object

test/cases/coerced_tests.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,6 @@ def test_views_coerced
578578
assert_includes @connection.views, Ebook.table_name
579579
end
580580

581-
# This is deprecated and we dont care in this version to pass it.
582-
coerce_tests! :test_table_exists
583-
584581
# We do better than ActiveRecord and find the views PK.
585582
coerce_tests! :test_does_not_assume_id_column_as_primary_key
586583
def test_does_not_assume_id_column_as_primary_key_coerced
@@ -594,9 +591,6 @@ class ViewWithoutPrimaryKeyTest < ActiveRecord::TestCase
594591
def test_views_coerced
595592
assert_includes @connection.views, Paperback.table_name
596593
end
597-
598-
# This is deprecated and we dont care in this version to pass it.
599-
coerce_tests! :test_table_exists
600594
end
601595

602596

0 commit comments

Comments
 (0)