Shell does not evaluate comparison operators correctly for NumberDecimal

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      The greater than and less than operator that compare NumberDecimals against each other seem to compare the string value rather than the actual numeric values against each other. See this repro:

      Less than operator:

       

       build/install/bin/mongo --nodb
      ================ Welcome to the MongoDB shell
      > let v1 = NumberDecimal("11"); 
      > let v2 = NumberDecimal("2"); 
      > let lt = v1 < v2; 
      > lt 
      true

      Greater than operator:

       

       > build/install/bin/mongo --nodb
      ================ 
      > let v1 = NumberDecimal("11"); 
      > let v2 = NumberDecimal("2"); 
      > let gt = v1 > v2;
      > gt
      false

            Assignee:
            Erin Liang
            Reporter:
            Erin Liang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: