-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: Query
-
None
The default scope docs have this bit:
Because a default scope initializes fields in new models as just described, defining a default scope with a dotted key and a simple literal value is not possible: .. code-block:: ruby class Band include Mongoid::Document field :name, type: String field :tags, type: Hash default_scope ->{ where('tags.foo' => 'bar') } end Band.create! # exception: BSON::String::IllegalKey ('tags.foo' is an illegal key in MongoDB. Keys may not start with '$' or contain a '.'.)
This behavior will change when driver accepts dots in field names, which will be a breaking change for Mongoid. There should be a test added to document the present behavior and documentation updated when the driver behavior changes.
- has to be finished together with
-
RUBY-2528 Permit inserting dollar-prefixed or dotted keys
- Closed