Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-840

Query.Not does not handle $where correctly

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.9
    • Affects Version/s: 1.8.3
    • Component/s: None
    • None
    • Major Change

      There is a mistake in the method Not() of MongoDB.Driver.Builders.Query.

      Line:
      MongoDB.Driver\Builders\QueryBuilder.cs(513): return new QueryDocument(elementName, new BsonDocument("$ne", operatorValue));

      Presumably there should be "$not" instead of "$ne".

      Now a valid Where query { "$where" :

      { "$code" : "this.Length == null" }

      } is converted by Not() into invalid { "$where" : { "$ne" :

      { "$code" : "this.Length == null" }

      } } which fails with an error:

      $where expression has an unexpected type (response:

      { "errmsg" : "exception: $where expression has an unexpected type", "code" : 15902, "ok" : 0.0 }

      )

      Driver version 1.8.3

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            nightroman Roman Kuzmin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: