Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-2138

$not + $regex gives different error code between 2.4. and 2.5

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • mongodb-2.6
    • Affects Version/s: mongodb-2.6
    • Component/s: manual
    • Labels:
    • Environment:

      Problem:
      For the given query

      db.q.find( {"s.a": {$not: {$regex:"0"}}})
      

      2.4.x and 2.5.x give different error codes.

      Reproduce:
      2.4.5

      > db.q.drop();
      true
      > db.q.insert(s: {a: "foo"}})
      > db.q.insert({s: {a: "foo"}})
      > db.q.find( {"s.a": {$not: {$regex:"0"}}})
      error: {
      	"$err" : "can't use $not with $regex, use BSON regex type instead",
      	"code" : 13032
      }
      

      2.5.3-pre

      > db.q.drop();
      true
      > db.q.insert({s: {a: "foo"}})
      > db.q.find( {"s.a": {$not: {$regex:"0"}}})
      error: { "$err" : "bad query: BadValue $not cannot have a regex", "code" : 16810 }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            alvin Alvin Richards (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              10 years, 28 weeks, 1 day ago