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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • 2.11.5
    • None
    • Bson, Builders
    • None
    • Windows/ASP.NET Core 3

    Description

      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"] }

      }}

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: