-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Attributes
When a field declared as a BSON::Binary is assigned a string value, this value remains as a string and appears to be persisted as a string:
class MyModel include Mongoid::Document field :data, type: BSON::Binary end irb(main):010:0> m = MyModel.new(data: 'test') => #<MyModel _id: 5df15c8b026d7c381b150ea4, data: "test"> irb(main):011:0> m.save! => true irb(main):012:0> m = MyModel.find(m.id) => #<MyModel _id: 5df15c8b026d7c381b150ea4, data: "test"> irb(main):013:0> m => #<MyModel _id: 5df15c8b026d7c381b150ea4, data: "test">
One would expect that the string would be converted to a BSON::Binary instance when the attribute is set in the model originally, then stored as a Binary.
- is duplicated by
-
MONGOID-4822 BSON 4.6.0 breaks saving of BSON::Binary fields
- Closed
- related to
-
MONGOID-4668 Strings assigned to Regexp fields get stored/retrieved as strings
- Closed
- links to