File tree Expand file tree Collapse file tree 6 files changed +12
-9
lines changed
lib/active_record/connection_adapters/abstract Expand file tree Collapse file tree 6 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 1
- * Deprecate ` in_clause_length ` in ` DatabaseLimits ` .
1
+ * Deprecate ` in_clause_length ` and ` allowed_index_name_length ` in ` DatabaseLimits ` .
2
2
3
3
* Ryuta Kamizono*
4
4
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ def table_name_length
32
32
def allowed_index_name_length
33
33
index_name_length
34
34
end
35
+ deprecate :allowed_index_name_length
35
36
36
37
# Returns the maximum length of an index name.
37
38
def index_name_length
Original file line number Diff line number Diff line change @@ -1441,10 +1441,8 @@ def extract_foreign_key_action(specifier)
1441
1441
end
1442
1442
1443
1443
def validate_index_length! ( table_name , new_name , internal = false )
1444
- max_index_length = internal ? index_name_length : allowed_index_name_length
1445
-
1446
- if new_name . length > max_index_length
1447
- raise ArgumentError , "Index name '#{ new_name } ' on table '#{ table_name } ' is too long; the limit is #{ allowed_index_name_length } characters"
1444
+ if new_name . length > index_name_length
1445
+ raise ArgumentError , "Index name '#{ new_name } ' on table '#{ table_name } ' is too long; the limit is #{ index_name_length } characters"
1448
1446
end
1449
1447
end
1450
1448
Original file line number Diff line number Diff line change @@ -411,6 +411,10 @@ def test_joins_per_query_is_deprecated
411
411
assert_deprecated { @connection . joins_per_query }
412
412
end
413
413
414
+ def test_allowed_index_name_length_is_deprecated
415
+ assert_deprecated { @connection . allowed_index_name_length }
416
+ end
417
+
414
418
unless current_adapter? ( :OracleAdapter )
415
419
def test_in_clause_length_is_deprecated
416
420
assert_deprecated { @connection . in_clause_length }
Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ def test_change_column_with_custom_index_name
254
254
255
255
def test_change_column_with_long_index_name
256
256
table_name_prefix = "test_models_"
257
- long_index_name = table_name_prefix + ( "x" * ( connection . allowed_index_name_length - table_name_prefix . length ) )
257
+ long_index_name = table_name_prefix + ( "x" * ( connection . index_name_length - table_name_prefix . length ) )
258
258
add_column "test_models" , "category" , :string
259
259
add_index :test_models , :category , name : long_index_name
260
260
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ def test_rename_index_too_long
44
44
e = assert_raises ( ArgumentError ) {
45
45
connection . rename_index ( table_name , "old_idx" , too_long_index_name )
46
46
}
47
- assert_match ( /too long; the limit is #{ connection . allowed_index_name_length } characters/ , e . message )
47
+ assert_match ( /too long; the limit is #{ connection . index_name_length } characters/ , e . message )
48
48
49
49
assert connection . index_name_exists? ( table_name , "old_idx" )
50
50
end
@@ -66,7 +66,7 @@ def test_add_index_does_not_accept_too_long_index_names
66
66
e = assert_raises ( ArgumentError ) {
67
67
connection . add_index ( table_name , "foo" , name : too_long_index_name )
68
68
}
69
- assert_match ( /too long; the limit is #{ connection . allowed_index_name_length } characters/ , e . message )
69
+ assert_match ( /too long; the limit is #{ connection . index_name_length } characters/ , e . message )
70
70
71
71
assert_not connection . index_name_exists? ( table_name , too_long_index_name )
72
72
connection . add_index ( table_name , "foo" , name : good_index_name )
@@ -229,7 +229,7 @@ def test_add_partial_index
229
229
230
230
private
231
231
def good_index_name
232
- "x" * connection . allowed_index_name_length
232
+ "x" * connection . index_name_length
233
233
end
234
234
end
235
235
end
You can’t perform that action at this time.
0 commit comments