[CSHARP-2739] The anonymous type-based projection produces invalid projection when hierarchial fields have common prefix Created: 10/Sep/19  Updated: 28/Oct/23  Resolved: 26/Sep/19

Status: Closed
Project: C# Driver
Component/s: Linq
Affects Version/s: 2.9.1
Fix Version/s: 2.9.2

Type: Bug Priority: Major - P3
Reporter: Aristarkh Zagorodnikov Assignee: Dmitry Lukyanov (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

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.



 Comments   
Comment by Githook User [ 27/Sep/19 ]

Author:

{'username': 'onyxmaster', 'email': 'xm@drive.net', 'name': 'Aristarkh Zagorodnikov'}

Message: CSHARP-2739: Improve hierarchical fields projection.
Branch: v2.9.x
https://github.com/mongodb/mongo-csharp-driver/commit/4908a9e01cdb199daeb0a8831cf0df97bfbc2ef1

Comment by Githook User [ 26/Sep/19 ]

Author:

{'name': 'Aristarkh Zagorodnikov', 'username': 'onyxmaster', 'email': 'xm@drive.net'}

Message: CSHARP-2739: Improve hierarchical fields projection.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/384d10d58d9dc308bd29e4eb0f1c8804ee954f39

Comment by Aristarkh Zagorodnikov [ 10/Sep/19 ]

https://github.com/mongodb/mongo-csharp-driver/pull/383

Generated at Wed Feb 07 21:43:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.