ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Unknown
    • 10.0.3, 9.1.3, 8.4.3
    • Affects Version/s: None
    • Component/s: None
    • None
    • Dotnet Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Projecting a scalar leaf reached through an owned (OwnsOne) hop silently returns null instead of the stored value. No exception, no warning — a plausible-looking result with a missing field.

      // Home is an OwnsOne; City is a stored scalar on it, Notes a collection.
      db.Blogs.Select(b => new { b.Home.City, b.Home.Notes }).ToList();
      // -> City == null for every row; Notes is correct.
      

      Scope, measured

      • Reproduces under the default Native mode and under explicit MongoQueryMode.DriverLinq.
      • Pre-existing — byte-identical at commit f8464860, i.e. it is not introduced by the step-3a bare-projection slice.
      • The array leaf beside it is correct; only the dotted scalar is lost.

      Mechanism

      The same read-side gap that EF-362 closed for arrays, in its scalar half. BsonBinding.GetPropertyValueAtElement builds a BsonSerializationInfo with a null ElementPath, so a dotted name is looked up as a literal key — while the emitted $project writes a nested document. The lookup misses and the lenient read yields null.

      EF-362 (delivered in step 3a) fixed the array side by giving GetBsonArray a segment-by-segment path walk. The scalar side was deliberately left alone as out of that slice's scope. TryReadElementValue already contains a path walk, so the fix is expected to be small and is located — but it must be measured, not assumed.

      Why this is filed separately

      This is the only silent-wrong-data item in this area without a ticket. Everything else comparable is either fixed, pinned with an owner, or has a JIRA number. Silent wrong data with a plausible shape is the highest-severity failure class in this subsystem: the surrounding work has repeatedly found that a wrong read presents as null for a nullable scalar and as an empty collection for an array, never as an error.

      Current state

      Pinned as measured, not correct by Ef362OwnedHopArrayProjectionTests.Owned_hop_SCALAR_leaf_alongside_the_array_leaf_is_still_declined_and_still_loses_the_scalar. That test asserts today's wrong behaviour so it cannot drift unnoticed — it must be inverted when this is fixed, not deleted.

      Also recorded in docs/native-query-status-EF-322.md §5 (bullet 4a) and in the EF-362 as-built note in src/MongoDB.EntityFrameworkCore/Query/AGENTS.md.

            Assignee:
            Arthur Vickers
            Reporter:
            Arthur Vickers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: