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

When ordering page 2 of geospatial query contains results from page 1

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

      When ordering by created_at page 2 of a geospatial query contains results from page 1:

      class Bar
        include Mongoid::Document
        include Mongoid::Timestamps
      
        field :location, type: Array
      
        index :'location' => "2d"
      
        def self.run_test
      
          #error does not always show up in first iteration
          for i in 1..100
            Bar.delete_all
            puts "it number " + i.to_s
      
            for j in 1..100
              Bar.create(:location => [10,10])
            end
      
            test  = Bar.near(:'location' => [10,10]).order_by( :'created_at'.asc ).page(1).per(2)
            test1_ids = []
            test.each do |tst|
              test1_ids << tst.id
            end
      
            test2  = Bar.near(:'location' => [10,10]).order_by( :'created_at'.asc ).page(2).per(2)
      
            test2_ids = []
            test2.each do |tst|
              test2_ids << tst.id
            end
      
            if ( test1_ids & test2_ids ).length > 0
              raise "unexpected duplicate elements:" +  ( test1_ids & test2_ids ).to_json
            end
      
      
          end
      
        end
      end
      

            Assignee:
            durran Durran Jordan
            Reporter:
            digitalplaywright digitalplaywright
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: