Skip to content

Commit f0ff483

Browse files
committed
[Rails5] Support deprecations on tables with name arg.
1 parent ff924f9 commit f0ff483

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/active_record/connection_adapters/sqlserver/schema_statements.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ def native_database_types
77
@native_database_types ||= initialize_native_database_types.freeze
88
end
99

10-
def tables(table_type = 'BASE TABLE')
11-
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'
10+
def tables(name = nil)
11+
ActiveSupport::Deprecation.warn 'Passing arguments to #tables is deprecated without replacement.' if name
12+
tables_sql('BASE TABLE')
1213
end
1314

1415
def table_exists?(table_name)
@@ -27,7 +28,7 @@ def data_source_exists?(table_name)
2728
end
2829

2930
def views
30-
tables('VIEW')
31+
tables_sql('VIEW')
3132
end
3233

3334
def view_exists?(table_name)
@@ -276,6 +277,12 @@ def initialize_native_database_types
276277
}
277278
end
278279

280+
def tables_sql(type)
281+
tn = lowercase_schema_reflection_sql 'TABLE_NAME'
282+
sql = "SELECT #{tn} FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = '#{type}' ORDER BY TABLE_NAME"
283+
select_values sql, 'SCHEMA'
284+
end
285+
279286
def column_definitions(table_name)
280287
identifier = if database_prefix_remote_server?
281288
SQLServer::Utils.extract_identifiers("#{database_prefix}#{table_name}")

0 commit comments

Comments
 (0)