From 6efe2b490083c90550786ab70957e8dc548baf23 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Tue, 9 Mar 2021 09:19:35 +0900 Subject: [PATCH] Use `type.serializable?` in `unboundable?` --- .../lib/active_record/relation/query_attribute.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/activerecord/lib/active_record/relation/query_attribute.rb b/activerecord/lib/active_record/relation/query_attribute.rb index cd18f27330..fdd69a806e 100644 --- a/activerecord/lib/active_record/relation/query_attribute.rb +++ b/activerecord/lib/active_record/relation/query_attribute.rb @@ -31,14 +31,10 @@ module ActiveRecord end def unboundable? - if defined?(@_unboundable) - @_unboundable - else - value_for_database unless value_before_type_cast.is_a?(StatementCache::Substitute) - @_unboundable = nil + unless defined?(@_unboundable) + @_unboundable = !type.serializable?(value) && type.cast(value) <=> 0 end - rescue ::RangeError - @_unboundable = type.cast(value_before_type_cast) <=> 0 + @_unboundable end private