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

The anonymous type-based projection produces invalid projection when hierarchial fields have common prefix

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.9.1
    • Fix Version/s: 2.9.2
    • Component/s: Linq
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible

      Description

      Consider the following test:

              [Fact]
              public void Should_translate_with_a_hierarchical_redundancy_and_when_one_field_doesnt_start_with_another()
              {
                  var result = Project(p => new { p.C.E, F = p.C.E1.F }, "{ C : { E : { H : 3 }, E1 : { F : 2 } } }");
       
                  result.Projection.Should().Be("{ \"C.E\" : 1, \"C.E1.F\" : 1, _id : 0 }");
       
                  result.Value.E.H.Should().Be(3);
                  result.Value.F.Should().Be(2);
              }
      

      With released 2.9.1 this test fails, because the FindProjectionTranslator.GetUniqueFieldsByHierarchy does not use periods to determine the common prefix.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: