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

Ordering embedded documents by id raises exception

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.0.0
    • Affects Version/s: None
    • Component/s: None
    • None

      I've added a spec to illustrate the behavior. The spec fails with:

      Failures:

      1) Mongoid::Relations::Embedded::Many when the embedded relation sorts on a boolean orders by id
      Failure/Error: circuit.reload.buses.asc(:id).should eq([ bus_one, bus_two ])
      ArgumentError:
      comparison of Bus with Bus failed

      1. ./lib/mongoid/contextual/memory.rb:379:in `sort!'
      2. ./lib/mongoid/contextual/memory.rb:379:in `block in in_place_sort'
      3. ./lib/mongoid/contextual/memory.rb:378:in `each_pair'
      4. ./lib/mongoid/contextual/memory.rb:378:in `in_place_sort'
      5. ./lib/mongoid/contextual/memory.rb:344:in `apply_sorting'
      6. ./lib/mongoid/contextual/memory.rb:168:in `initialize'
      7. ./lib/mongoid/contextual.rb:47:in `new'
      8. ./lib/mongoid/contextual.rb:47:in `create_context'
      9. ./lib/mongoid/contextual.rb:30:in `context'
      10. ./lib/mongoid/contextual.rb:18:in `each'
      11. ./lib/mongoid/criteria.rb:34:in `entries'
      12. ./lib/mongoid/criteria.rb:34:in `=='
      13. ./spec/mongoid/relations/embedded/many_spec.rb:3311:in `block (3 levels) in <top (required)>'

            Assignee:
            Unassigned Unassigned
            Reporter:
            jpmckinney jpmckinney
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: