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

Non-nullable members cannot be compared to nullable values

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.4.1
    • Affects Version/s: 2.3
    • Component/s: API
    • None

      This is a regression from 2.3 -> 2.4. When upgrading to 2.4 it broke all these queries.

      When doing a query such a Find where the filter is 'd => d._id == nullableId' where nullableId is a Guid? (Nullable<Guid>) there is a unsupported filter exception that throws. Here is the exception: System.ArgumentException: Unsupported filter: (Convert(

      {document}

      {_id}) == 61d29f4c-7e8a-4eb6-b7ce-c1cbbc9cd1b2).

      More info:

      • we do a BsonRepresentation(BsonType.String) for all of our guids
      • changing the query to d => d._id == nullableId.Value fixes the issue
      • this is a regression

      This is a non blocking issue because we can just add .Value to the nullable guid and it works

      Note: this actually applies to all non-nullable members compared to nullable values, not just Guid.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            Gekctek Ethan [X]
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: