-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: Attributes, Query
Although Mongoid takes into account the the type of the fields defined in a class to build the Queries selectors, it fails to take into account the embedded records' attributes type. See the example below:
class Person include Mongoid::Document field :name, type: String field :age, type: Integer embeds_one :address accepts_nested_attributes_for :address end class Address include Mongoid::Document field :zip_code, type: String field :number, type: Integer embedded_in :company end query = Person.where(age: "28", "address.number" => "1000", "address.zip_code" => "72000-123") # => #<Mongoid::Criteria # selector: {"age"=>28, "address.number"=>"1000", "address.zip_code"=>"72000-123"} # options: {} # class: Person # embedded: false>
Since Mongoid provides a clean interface for querying objects based on embedded records' attributes, I was expecting it to consider the types of embedded class fields, although this behavior is not explicitly documented.
However, I'm not sure whether this should be considered a bug or a new feature
Thanks in advance.
- is related to
-
MONGOID-5267 Remove driver argument in Queryable constructor
- Closed