Skip to content

Commit 95b48d8

Browse files
committed
Remove deprecated support to quote ActiveSupport::Duration
1 parent 240e9da commit 95b48d8

File tree

7 files changed

+8
-39
lines changed

7 files changed

+8
-39
lines changed

activerecord/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove deprecated support to quote `ActiveSupport::Duration`.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated `#quote_bound_value`.
26

37
*Rafael Mendonça França*

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ def quote(value)
2323
when Type::Time::Value then "'#{quoted_time(value)}'"
2424
when Date, Time then "'#{quoted_date(value)}'"
2525
when Class then "'#{value}'"
26-
when ActiveSupport::Duration
27-
warn_quote_duration_deprecated
28-
value.to_s
2926
else raise TypeError, "can't quote #{value.class.name}"
3027
end
3128
end
@@ -229,22 +226,6 @@ def type_casted_binds(binds)
229226
def lookup_cast_type(sql_type)
230227
type_map.lookup(sql_type)
231228
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
248229
end
249230
end
250231
end

activerecord/test/cases/adapters/abstract_mysql_adapter/bind_parameter_test.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ def test_where_with_rational_for_string_column_using_bind_parameters
7272
assert_quoted_as "'0.0'", Rational(0)
7373
end
7474

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-
8175
private
8276
def assert_quoted_as(expected, value)
8377
relation = Post.where("title = ?", value)

activerecord/test/cases/adapters/postgresql/bind_parameter_test.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ def test_where_with_rational_for_string_column_using_bind_parameters
3333
assert_quoted_as "0/1", Rational(0), valid: false
3434
end
3535

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-
4236
private
4337
def assert_quoted_as(expected, value, valid: true)
4438
relation = Post.where("title = ?", value)

activerecord/test/cases/adapters/sqlite3/bind_parameter_test.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ def test_where_with_rational_for_string_column_using_bind_parameters
3333
assert_quoted_as "0/1", Rational(0)
3434
end
3535

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-
4236
private
4337
def assert_quoted_as(expected, value)
4438
relation = Post.where("title = ?", value)

activerecord/test/cases/quoting_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ def test_quote_as_mb_chars_no_column
191191
end
192192

193193
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
196196
end
197197
end
198198

guides/source/7_2_release_notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ Please refer to the [Changelog][active-record] for detailed changes.
158158

159159
* Remove deprecated `#quote_bound_value`.
160160

161+
* Remove deprecated support to quote `ActiveSupport::Duration`.
162+
161163
### Deprecations
162164

163165
* Deprecate `Rails.application.config.active_record.allow_deprecated_singular_associations_name`

0 commit comments

Comments
 (0)