File tree Expand file tree Collapse file tree 7 files changed +8
-39
lines changed
lib/active_record/connection_adapters/abstract Expand file tree Collapse file tree 7 files changed +8
-39
lines changed Original file line number Diff line number Diff line change
1
+ * Remove deprecated support to quote ` ActiveSupport::Duration ` .
2
+
3
+ * Rafael Mendonça França*
4
+
1
5
* Remove deprecated ` #quote_bound_value ` .
2
6
3
7
* Rafael Mendonça França*
Original file line number Diff line number Diff line change @@ -23,9 +23,6 @@ def quote(value)
23
23
when Type ::Time ::Value then "'#{ quoted_time ( value ) } '"
24
24
when Date , Time then "'#{ quoted_date ( value ) } '"
25
25
when Class then "'#{ value } '"
26
- when ActiveSupport ::Duration
27
- warn_quote_duration_deprecated
28
- value . to_s
29
26
else raise TypeError , "can't quote #{ value . class . name } "
30
27
end
31
28
end
@@ -229,22 +226,6 @@ def type_casted_binds(binds)
229
226
def lookup_cast_type ( sql_type )
230
227
type_map . lookup ( sql_type )
231
228
end
232
-
233
- def warn_quote_duration_deprecated
234
- ActiveRecord . deprecator . warn ( <<~MSG )
235
- Using ActiveSupport::Duration as an interpolated bind parameter in an SQL
236
- string template is deprecated. To avoid this warning, you should explicitly
237
- convert the duration to a more specific database type. For example, if you
238
- want to use a duration as an integer number of seconds:
239
- ```
240
- Record.where("duration = ?", 1.hour.to_i)
241
- ```
242
- If you want to use a duration as an ISO 8601 string:
243
- ```
244
- Record.where("duration = ?", 1.hour.iso8601)
245
- ```
246
- MSG
247
- end
248
229
end
249
230
end
250
231
end
Original file line number Diff line number Diff line change @@ -72,12 +72,6 @@ def test_where_with_rational_for_string_column_using_bind_parameters
72
72
assert_quoted_as "'0.0'" , Rational ( 0 )
73
73
end
74
74
75
- def test_where_with_duration_for_string_column_using_bind_parameters
76
- assert_deprecated ( ActiveRecord . deprecator ) do
77
- assert_quoted_as "'0'" , 0 . seconds
78
- end
79
- end
80
-
81
75
private
82
76
def assert_quoted_as ( expected , value )
83
77
relation = Post . where ( "title = ?" , value )
Original file line number Diff line number Diff line change @@ -33,12 +33,6 @@ def test_where_with_rational_for_string_column_using_bind_parameters
33
33
assert_quoted_as "0/1" , Rational ( 0 ) , valid : false
34
34
end
35
35
36
- def test_where_with_duration_for_string_column_using_bind_parameters
37
- assert_deprecated ( ActiveRecord . deprecator ) do
38
- assert_quoted_as "0" , 0 . seconds , valid : false
39
- end
40
- end
41
-
42
36
private
43
37
def assert_quoted_as ( expected , value , valid : true )
44
38
relation = Post . where ( "title = ?" , value )
Original file line number Diff line number Diff line change @@ -33,12 +33,6 @@ def test_where_with_rational_for_string_column_using_bind_parameters
33
33
assert_quoted_as "0/1" , Rational ( 0 )
34
34
end
35
35
36
- def test_where_with_duration_for_string_column_using_bind_parameters
37
- assert_deprecated ( ActiveRecord . deprecator ) do
38
- assert_quoted_as "0" , 0 . seconds
39
- end
40
- end
41
-
42
36
private
43
37
def assert_quoted_as ( expected , value )
44
38
relation = Post . where ( "title = ?" , value )
Original file line number Diff line number Diff line change @@ -191,8 +191,8 @@ def test_quote_as_mb_chars_no_column
191
191
end
192
192
193
193
def test_quote_duration
194
- expected = assert_deprecated ( ActiveRecord . deprecator ) { @quoter . quote ( 30 . minutes ) }
195
- assert_equal "1800 " , expected
194
+ exception = assert_raises ( TypeError ) { @quoter . quote ( 30 . minutes ) }
195
+ assert_equal "can't quote ActiveSupport::Duration " , exception . message
196
196
end
197
197
end
198
198
Original file line number Diff line number Diff line change @@ -158,6 +158,8 @@ Please refer to the [Changelog][active-record] for detailed changes.
158
158
159
159
* Remove deprecated ` #quote_bound_value ` .
160
160
161
+ * Remove deprecated support to quote ` ActiveSupport::Duration ` .
162
+
161
163
### Deprecations
162
164
163
165
* Deprecate ` Rails.application.config.active_record.allow_deprecated_singular_associations_name `
You can’t perform that action at this time.
0 commit comments