Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2675

QueryCache returns wrong results after partial iteration of result set, e.g. after calling `none?`

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.14.1, 2.15.1
    • Affects Version/s: 2.14.0
    • Component/s: Query
    • None
    • Environment:
      Ubuntu 20.04
    • Fully Compatible

      I have a simple model where a Farm has_many Crops and Crop belongs_to Farm. If I  call `farm.crops.none?`, it appears to cache the wrong value for crops in the QueryCache and subsequent calls to farm.crops only list 1 crop, even if there are 5 associated crops.

       

      For example:

      ```

      3.0.0 :003 > farm = Farm.first
      => #<Farm _id: 609d35aefc70933c95aa9732, ...>
      3.0.0 :004 > farm.crops.count
      => 5
      3.0.0 :005 > farm.crops.none?
      => false
      3.0.0 :006 > farm.crops
      =>  [#<Crop _id: 60c01fd0fc7093b20bcdb452, ...>]   <= Notice only 1 crop in the array, should be 5
      3.0.0 :007 > farm.crops.count
      => 5
      3.0.0 :008 > farm.crops.to_a.count
      => 1

      ```

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            aaron@propagateventures.com Aaron Davis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: