Skip to content

Commit 21c8e5c

Browse files
committed
Remove deprecated support to type cast to database values ActiveRecord::Base objects
1 parent 8311df4 commit 21c8e5c

File tree

4 files changed

+6
-33
lines changed

4 files changed

+6
-33
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 type cast to database values `ActiveRecord::Base` objects.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated support to quote `ActiveRecord::Base` objects.
26

37
*Rafael Mendonça França*

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ def quote(value)
1616
# SQLite does not understand dates, so this method will convert a Date
1717
# to a String.
1818
def type_cast(value, column = nil)
19-
if value.is_a?(Base)
20-
ActiveSupport::Deprecation.warn(<<~MSG)
21-
Passing an Active Record object to `type_cast` directly is deprecated
22-
and will be no longer type casted as id value in Rails 7.0.
23-
MSG
24-
value = value.id_for_database
25-
end
26-
2719
if column
2820
ActiveSupport::Deprecation.warn(<<~MSG)
2921
Passing a column to `type_cast` is deprecated and will be removed in Rails 7.0.

activerecord/test/cases/quoting_test.rb

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -248,30 +248,5 @@ def test_type_cast_returns_frozen_value
248248
assert_predicate @connection.type_cast(false), :frozen?
249249
end
250250
end
251-
252-
if supports_datetime_with_precision?
253-
class QuoteARBaseTest < ActiveRecord::TestCase
254-
class DatetimePrimaryKey < ActiveRecord::Base
255-
end
256-
257-
def setup
258-
@time = ::Time.utc(2017, 2, 14, 12, 34, 56, 789999)
259-
@connection = ActiveRecord::Base.connection
260-
@connection.create_table :datetime_primary_keys, id: :datetime, precision: 3, force: true
261-
end
262-
263-
def teardown
264-
@connection.drop_table :datetime_primary_keys, if_exists: true
265-
end
266-
267-
def test_type_cast_ar_object
268-
value = DatetimePrimaryKey.new(id: @time)
269-
expected = @connection.type_cast(value.id)
270-
assert_deprecated do
271-
assert_equal expected, @connection.type_cast(value)
272-
end
273-
end
274-
end
275-
end
276251
end
277252
end

guides/source/7_0_release_notes.md

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

121121
* Remove deprecated support to quote `ActiveRecord::Base` objects.
122122

123+
* Remove deprecated support to type cast to database values `ActiveRecord::Base` objects.
124+
123125
### Deprecations
124126

125127
### Notable changes

0 commit comments

Comments
 (0)