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

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.9.2
    • Affects Version/s: 2.9.1
    • Component/s: Linq
    • Labels:
      None
    • Fully Compatible

      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.

            Assignee:
            dmitry.lukyanov@mongodb.com Dmitry Lukyanov (Inactive)
            Reporter:
            onyxmaster Aristarkh Zagorodnikov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: