We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 211d466 commit db1eb4cCopy full SHA for db1eb4c
lib/mongoid/attributes.rb
@@ -371,7 +371,12 @@ def lookup_attribute_presence(name, value)
371
# comparison purposes. This is necessary because `BSON::Decimal128` does
372
# not implement `#==` in a way that is compatible with `BigDecimal`.
373
def normalize_value(value)
374
- value.is_a?(BSON::Decimal128) ? BigDecimal(value.to_s) : value
+ if value.is_a?(BSON::Decimal128)
375
+ # BSON::Decimal128#to_d was introduced in driver version 5.0.0
376
+ value.respond_to?(:to_d) ? value.to_d : BigDecimal(value.to_s)
377
+ else
378
+ value
379
+ end
380
end
381
382
# Determine if the attribute will not change, by comparing the current
0 commit comments