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

QueryCache ignores getMore requests

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 7.1.0.rc0, 7.0.3
    • Affects Version/s: 5.2.1
    • Component/s: None
    • None
    • 1

      I have a simple class:

      class Article
        include Mongoid::Document
      end
      

      Let's create at least 102 records (because the default batchSize of mongodb is 101):

      102.times { Article.create }
      

      Now if I make this query with the QueryCache enabled:

      Mongoid::QueryCache.cache { Article.all.any?; Article.all.map(&:id).size }
      => 101
      

      It does not return the correct number of articles which should be 102.

      After some investigation, the reason is that the 2 commands make the same queries... except that the map makes a getMore to get the rest of the list. The QueryCache prevents the getMore from being made.

      A workaround could be to use exists? or empty? but we clearly should not have an issue with any? too.

            Assignee:
            sam.rossi@mongodb.com Samuel Rossi (Inactive)
            Reporter:
            CedricBm Cedric Beaumont
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: