Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-61430

Raise an error when $mod remainder is not a number

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • 4.2.18
    • Affects Version/s: 4.2.17
    • Component/s: None
    • ALL
    • QE 2021-12-13, QE 2021-12-27

      Current implementation of $mod in v4.2 doesn't raise an error when the remainder is not a number:
      db.xxx.find({a: {$mod: [2,'z']}});
      { "_id" : 2, "a" : 2, "b" : "bar" }

      The problem stems from https://github.com/mongodb/mongo/blob/f6690d2a4803b3a316bf8f5ba859af35bd433b9b/src/mongo/db/matcher/expression_parser.cpp#L449

      which should be

      if (!r.isNumber())

            Assignee:
            romans.kasperovics@mongodb.com Romans Kasperovics
            Reporter:
            milena.ivanova@mongodb.com Milena Ivanova
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: