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

$regex query should assert if value is not a regex or a string

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.5.5
    • Affects Version/s: 2.0.2
    • Component/s: Querying
    • Environment:
      Tested on Windows 7 64-bit but should be the same on all platforms.
    • ALL

      To reproduce:

      > db.test.remove()
      > db.test.insert(

      {t:"a"}

      )
      > db.test.insert(

      {t:"b"}

      )
      > db.test.find({t:{$regex:[/^x/,/^y/]}})

      { "_id" : ObjectId("4f3530db0105ec90fee42bbd"), "t" : "a" } { "_id" : ObjectId("4f3530df0105ec90fee42bbe"), "t" : "b" }

      >

      The intent of the query was to return documents where t starts with "x" or "y", but the query is malformed. However, the server doesn't return any sort of error message and instead appears to just return all documents in the collection.

      The server should return an error message if the value of $regex is not a regular expression or a string.

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: