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

Raise an error when $mod remainder is not a number

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • 4.2.17
    • 4.2.18
    • None
    • ALL
    • QE 2021-12-13, QE 2021-12-27

    Description

      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())

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: