Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-6703

Investigate changes in SERVER-68922: $natural parser should be stricter (reject NaN, etc)

    • Type: Icon: Investigation Investigation
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • No version
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed

      Original Downstream Change Summary

      This change brings the server-side validation in line with what we say that we accept in our public documentation (see https://www.mongodb.com/docs/manual/reference/method/cursor.hint/#std-label-hint-collection-scans), so there should not be any documentation changes needed. However, sending downstream impact tickets to notify that we will now reject invalid inputs rather than interpreting them non-sensically.

      Description of Linked Ticket

      A $natural hint or sort is supposed to take a direction: +1 or -1. But the parser allows other values, such as 0, NaN, or -0.01. In 5.0 and later we define safeNumberInt() < 0 to mean descending, which means 0, NaN and -0.01 are ascending. In 4.4 and earlier we use the unsafe numberInt(), so whether NaN is ascending or descending depends on the platform.

      We should reject all of these inputs with a clear error. We should also consider using the number() < 0 idiom for consistency with index keys and sort patterns.

      It looks like this doesn't affect other hints and sorts, because we either validate the SortPattern, or check that the hint matches to an existing index key.

            Assignee:
            Unassigned Unassigned
            Reporter:
            backlog-server-pm Backlog - Core Eng Program Management Team
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: