Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1811

Raise a deprecation warning for min/max queries that don't contain a hint

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.8
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      4.1.10 seems to have a breaking change related to how Cursor.min ($min) and Cursor.max ($max):

       [2019/04/12 12:52:28.718] db version v4.1.10-55-g092e71eab0
       [2019/04/12 12:52:28.718] git version: 092e71eab06999437d8df8ab3e023219fc593963
      
       [2019/04/12 12:55:29.000] ERROR [0.043s]: test_min_query (test_collection.TestCollection)
       [2019/04/12 12:55:29.000] ----------------------------------------------------------------------
       [2019/04/12 12:55:29.000] Traceback (most recent call last):
       [2019/04/12 12:55:29.000]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/test/test_collection.py", line 2004, in test_min_query
       [2019/04/12 12:55:29.000]     "$query": {}}))))
       [2019/04/12 12:55:29.000]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/cursor.py", line 1122, in next
       [2019/04/12 12:55:29.000]     if len(self.__data) or self._refresh():
       [2019/04/12 12:55:29.000]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/cursor.py", line 1039, in _refresh
       [2019/04/12 12:55:29.000]     self.__send_message(q)
       [2019/04/12 12:55:29.000]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/cursor.py", line 929, in __send_message
       [2019/04/12 12:55:29.000]     unpack_res=self._unpack_response)
       [2019/04/12 12:55:29.000]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/mongo_client.py", line 1271, in _send_message_with_response
       [2019/04/12 12:55:29.000]     exhaust=exhaust)
       [2019/04/12 12:55:29.000]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/mongo_client.py", line 1426, in _retryable_read
       [2019/04/12 12:55:29.000]     return func(session, server, sock_info, slave_ok)
       [2019/04/12 12:55:29.000]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/mongo_client.py", line 1265, in _cmd
       [2019/04/12 12:55:29.000]     unpack_res)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/server.py", line 122, in send_message_with_response
       [2019/04/12 12:55:29.001]     _check_command_response(first)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/helpers.py", line 155, in _check_command_response
       [2019/04/12 12:55:29.001]     raise OperationFailure(msg % errmsg, code, response)
       [2019/04/12 12:55:29.001] OperationFailure: error processing query: ns=pymongo_test.testTree: $and
       [2019/04/12 12:55:29.001] Sort: {}
       [2019/04/12 12:55:29.001] Proj: {}
       [2019/04/12 12:55:29.001]  planner returned error :: caused by :: When using min()/max() a hint of which index to use must be provided
       [2019/04/12 12:55:29.001] ======================================================================
       [2019/04/12 12:55:29.001] ERROR [0.034s]: test_max (test_cursor.TestCursor)
       [2019/04/12 12:55:29.001] ----------------------------------------------------------------------
       [2019/04/12 12:55:29.001] Traceback (most recent call last):
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/test/test_cursor.py", line 460, in test_max
       [2019/04/12 12:55:29.001]     self.assertEqual(len(list(cursor)), 3)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/cursor.py", line 1122, in next
       [2019/04/12 12:55:29.001]     if len(self.__data) or self._refresh():
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/cursor.py", line 1039, in _refresh
       [2019/04/12 12:55:29.001]     self.__send_message(q)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/cursor.py", line 929, in __send_message
       [2019/04/12 12:55:29.001]     unpack_res=self._unpack_response)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/mongo_client.py", line 1271, in _send_message_with_response
       [2019/04/12 12:55:29.001]     exhaust=exhaust)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/mongo_client.py", line 1426, in _retryable_read
       [2019/04/12 12:55:29.001]     return func(session, server, sock_info, slave_ok)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/mongo_client.py", line 1265, in _cmd
       [2019/04/12 12:55:29.001]     unpack_res)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/server.py", line 122, in send_message_with_response
       [2019/04/12 12:55:29.001]     _check_command_response(first)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/helpers.py", line 155, in _check_command_response
       [2019/04/12 12:55:29.001]     raise OperationFailure(msg % errmsg, code, response)
       [2019/04/12 12:55:29.001] OperationFailure: error processing query: ns=pymongo_test.testTree: $and
       [2019/04/12 12:55:29.001] Sort: {}
       [2019/04/12 12:55:29.001] Proj: {}
       [2019/04/12 12:55:29.001]  planner returned error :: caused by :: When using min()/max() a hint of which index to use must be provided
       [2019/04/12 12:55:29.001] ======================================================================
       [2019/04/12 12:55:29.001] ERROR [0.030s]: test_min (test_cursor.TestCursor)
       [2019/04/12 12:55:29.001] ----------------------------------------------------------------------
       [2019/04/12 12:55:29.001] Traceback (most recent call last):
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/test/test_cursor.py", line 490, in test_min
       [2019/04/12 12:55:29.001]     self.assertEqual(len(list(cursor)), 7)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/cursor.py", line 1122, in next
       [2019/04/12 12:55:29.001]     if len(self.__data) or self._refresh():
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/cursor.py", line 1039, in _refresh
       [2019/04/12 12:55:29.001]     self.__send_message(q)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/cursor.py", line 929, in __send_message
       [2019/04/12 12:55:29.001]     unpack_res=self._unpack_response)
       [2019/04/12 12:55:29.001]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/mongo_client.py", line 1271, in _send_message_with_response
       [2019/04/12 12:55:29.002]     exhaust=exhaust)
       [2019/04/12 12:55:29.002]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/mongo_client.py", line 1426, in _retryable_read
       [2019/04/12 12:55:29.002]     return func(session, server, sock_info, slave_ok)
       [2019/04/12 12:55:29.002]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/mongo_client.py", line 1265, in _cmd
       [2019/04/12 12:55:29.002]     unpack_res)
       [2019/04/12 12:55:29.002]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/server.py", line 122, in send_message_with_response
       [2019/04/12 12:55:29.003]     _check_command_response(first)
       [2019/04/12 12:55:29.003]   File "/data/mci/9df668337493a7babfd9f4f8a1472d87/src/pymongo/helpers.py", line 155, in _check_command_response
       [2019/04/12 12:55:29.003]     raise OperationFailure(msg % errmsg, code, response)
       [2019/04/12 12:55:29.003] OperationFailure: error processing query: ns=pymongo_test.testTree: $and
       [2019/04/12 12:55:29.003] Sort: {}
       [2019/04/12 12:55:29.003] Proj: {}
       [2019/04/12 12:55:29.003]  planner returned error :: caused by :: When using min()/max() a hint of which index to use must be provided
      

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: