Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4246

Objects are not properly evolved to ObjectIds in #where for polymorphic relations

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.2
    • Affects Version/s: None
    • Component/s: None
    • None

      When providing an object related via a polymoprhic association to #where, the object is not properly converted to an ObjectId in the query.

      Rating.where(ratable: movie)
      => NoMethodError: undefined method `bson_type' for #<Movie _id: 56cf079df1286e1284dcb98b, title: nil>
      

      The criteria looks like:

      => #<Mongoid::Criteria
      selector: {"ratable_id"=>#<Movie _id: 56cf07ccf1286e1286530b03, title: nil>}
      options:  {}
      class:    Rating
      embedded: false>
      

      it should have an ObjectId in the selector instead of a movie object.

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            emily.stolfo Emily Stolfo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: