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

#first and #last change previous criteria

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

      order_criteria = Order.desc(:name)
       => #<Mongoid::Criteria
        selector: {:deleted_at=>nil},
        options:  {:sort=>[[:name, :desc]]},
        class:    Order,
        embedded: false>
       
      order_criteria.first
       => #<Order _id: 4e8e8b169759f77a73000001 ... > 
      
      order_criteria
       => #<Mongoid::Criteria
        selector: {:deleted_at=>nil},
        options:  {:sort=>[[:name, :desc], [:_id, :asc]]},
        class:    Order,
        embedded: false>
      

      And even more curious:

      order_criteria = Order.desc(:_id)
       => #<Mongoid::Criteria
        selector: {:deleted_at=>nil},
        options:  {:sort=>[[:_id, :desc]]},
        class:    Order,
        embedded: false>
       
      order_criteria.first
       => #<Order _id: 4e8e8b169759f77a73000001 ... > 
      
      order_criteria
       => #<Mongoid::Criteria
        selector: {:deleted_at=>nil},
        options:  {:sort=>[[:_id, :desc], [:_id, :asc]]},
        class:    Order,
        embedded: false>
      

      I think these methods better should work with duplicates of criterion

            Assignee:
            Unassigned Unassigned
            Reporter:
            mik-die Mikhail Dieterle
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: