mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #35029 from dylanahsmith/fix-strictly-cast-attribute-types
activerecord: Fix statement cache for strictly cast attributes
This commit is contained in:
commit
060fe16447
2 changed files with 7 additions and 1 deletions
|
@ -32,7 +32,7 @@ module ActiveRecord
|
|||
if defined?(@_unboundable)
|
||||
@_unboundable
|
||||
else
|
||||
value_for_database
|
||||
value_for_database unless value_before_type_cast.is_a?(StatementCache::Substitute)
|
||||
@_unboundable = nil
|
||||
end
|
||||
rescue ::RangeError
|
||||
|
|
|
@ -4,6 +4,7 @@ require "cases/helper"
|
|||
require "models/book"
|
||||
require "models/liquid"
|
||||
require "models/molecule"
|
||||
require "models/numeric_data"
|
||||
require "models/electron"
|
||||
|
||||
module ActiveRecord
|
||||
|
@ -74,6 +75,11 @@ module ActiveRecord
|
|||
assert_equal "salty", liquids[0].name
|
||||
end
|
||||
|
||||
def test_statement_cache_with_strictly_cast_attribute
|
||||
row = NumericData.create(temperature: 1.5)
|
||||
assert_equal row, NumericData.find_by(temperature: 1.5)
|
||||
end
|
||||
|
||||
def test_statement_cache_values_differ
|
||||
cache = ActiveRecord::StatementCache.create(Book.connection) do |params|
|
||||
Book.where(name: "my book")
|
||||
|
|
Loading…
Reference in a new issue