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

PipelineDefinitionBuilder.Match() method generates incorrect BsonDocument for equality filter

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.11.5
    • Component/s: BSON, Builders
    • Labels:
      None
    • Environment:
      Windows/ASP.NET Core 3

      I have the following code:

      PipelineDefinitionBuilder.Match<BsonDocument, BsonDocument>(myPipeline, Builders<BsonDocument>.Filter.Eq("$_id", "$$userId"));

      I expect the generated BsonDocument to be:

      {{

      { "$eq": ["$_id", "$$userId"] }

      }}

      Instead I get this:

      {{

      { "$_id": "$$userId" }

      }}

      Which results in the aggregation command to fail with error:

      Command aggregate failed: unknown top level operator: $_id

      Other filters seems to work as expected. e.g

      PipelineDefinitionBuilder.Match<BsonDocument, BsonDocument>(myPipeline, Builders<BsonDocument>.Filter.Gt("$var1", "$$var2"));

      Generates:

      {{

      { "$gt": ["$var1", "$$var2"] }

      }}

            Assignee:
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Reporter:
            marwan@aouida.com Marwan Aouida
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: