Consider whether the LINQ provider should generate different MQL if it can detect that a field might be missing

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: 3.6.0
    • Component/s: LINQ
    • None
    • None
    • Dotnet Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      The LINQ provider assumes that all POCO properties used in LINQ queries are not missing from the document stored in the document.

      Sometimes this assumption results in unexpected results when the server treats missing fields as different than `null`.

      This was a deliberate assumption because we did not want to generate MQL that was more complex than necessary (and therefore slower) for the common case where fields are never missing.

      The guidance is that if you know a field might be missing you need to write your query accordingly.

      But users can easily miss this nuance, which results in JIRA tickets being reported, or worse, in users not realizing they are getting unexpected results.

      It is probably quite difficult to do this work.

      The first issue is that there is currently no interface defined that would allow the LINQ provider to figure out that a field might be missing (note that `[BsonIgnore]` is an attribute used while configuring a class map based serializer, but once the serializer has been created the fact that `[BsonIgnore]` was used is lost).

      Another issue is that if a new property is added to a POCO existing documents in the database won't have this field, even if this field is now mandatory for new documents. So we would need some way to model that even required fields might be missing in older documents.

      There very well could be other issues. So this effort involves a non-trivial amount of prior research before even beginning work.

            Assignee:
            Unassigned
            Reporter:
            Robert Stam (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: