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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.11.5
    • Fix Version/s: None
    • Component/s: Bson, Builders
    • Security Level: Public
    • Labels:
      None
    • Environment:
      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

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

              Dates

              Created:
              Updated:
              Resolved: