Skip to content

Commit e0a1235

Browse files
committed
Deprecate most methods which were never used in DatabaseLimits
`DatabaseLimits` and those methods were introduced at 3809c80, but most methods were never used and never tested from the beginning (except `table_alias_length`, `index_name_length`, and `in_clause_length` (since 66c0937)). There is no reason to maintain unused those methods for about 8 years.
1 parent bd932f5 commit e0a1235

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

activerecord/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
* Deprecate `column_name_length`, `table_name_length`, `columns_per_table`,
2+
`indexes_per_table`, `columns_per_multicolumn_index`, `sql_query_length`,
3+
and `joins_per_query` methods in `DatabaseLimits`.
4+
5+
*Ryuta Kamizono*
6+
17
* ActiveRecord::Base.configurations now returns an object.
28

39
ActiveRecord::Base.configurations used to return a hash, but this

activerecord/lib/active_record/connection_adapters/abstract/database_limits.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
require "active_support/deprecation"
4+
35
module ActiveRecord
46
module ConnectionAdapters # :nodoc:
57
module DatabaseLimits
@@ -12,11 +14,13 @@ def table_alias_length
1214
def column_name_length
1315
64
1416
end
17+
deprecate :column_name_length
1518

1619
# Returns the maximum length of a table name.
1720
def table_name_length
1821
64
1922
end
23+
deprecate :table_name_length
2024

2125
# Returns the maximum allowed length for an index name. This
2226
# limit is enforced by \Rails and is less than or equal to
@@ -36,16 +40,19 @@ def index_name_length
3640
def columns_per_table
3741
1024
3842
end
43+
deprecate :columns_per_table
3944

4045
# Returns the maximum number of indexes per table.
4146
def indexes_per_table
4247
16
4348
end
49+
deprecate :indexes_per_table
4450

4551
# Returns the maximum number of columns in a multicolumn index.
4652
def columns_per_multicolumn_index
4753
16
4854
end
55+
deprecate :columns_per_multicolumn_index
4956

5057
# Returns the maximum number of elements in an IN (x,y,z) clause.
5158
# +nil+ means no limit.
@@ -57,11 +64,13 @@ def in_clause_length
5764
def sql_query_length
5865
1048575
5966
end
67+
deprecate :sql_query_length
6068

6169
# Returns maximum number of joins in a single query.
6270
def joins_per_query
6371
256
6472
end
73+
deprecate :joins_per_query
6574
end
6675
end
6776
end

activerecord/test/cases/adapter_test.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,34 @@ def test_log_invalid_encoding
300300
def test_supports_multi_insert_is_deprecated
301301
assert_deprecated { @connection.supports_multi_insert? }
302302
end
303+
304+
def test_column_name_length_is_deprecated
305+
assert_deprecated { @connection.column_name_length }
306+
end
307+
308+
def test_table_name_length_is_deprecated
309+
assert_deprecated { @connection.table_name_length }
310+
end
311+
312+
def test_columns_per_table_is_deprecated
313+
assert_deprecated { @connection.columns_per_table }
314+
end
315+
316+
def test_indexes_per_table_is_deprecated
317+
assert_deprecated { @connection.indexes_per_table }
318+
end
319+
320+
def test_columns_per_multicolumn_index_is_deprecated
321+
assert_deprecated { @connection.columns_per_multicolumn_index }
322+
end
323+
324+
def test_sql_query_length_is_deprecated
325+
assert_deprecated { @connection.sql_query_length }
326+
end
327+
328+
def test_joins_per_query_is_deprecated
329+
assert_deprecated { @connection.joins_per_query }
330+
end
303331
end
304332

305333
class AdapterForeignKeyTest < ActiveRecord::TestCase

0 commit comments

Comments
 (0)