1919using MongoDB . Bson ;
2020using MongoDB . Bson . Serialization . Attributes ;
2121using MongoDB . Bson . Serialization . Options ;
22- using MongoDB . Driver . Linq ;
2322using Xunit ;
2423
2524namespace MongoDB . Driver . Tests . Linq . Linq3Implementation . Jira ;
@@ -31,84 +30,6 @@ public CSharp4443Tests(ClassFixture fixture)
3130 {
3231 }
3332
34- [ Fact ]
35- public void Projecting_dictionary_keys_with_arrayOfArrays_should_throw ( )
36- {
37- var exception = Record . Exception ( ( ) =>
38- {
39- _ = Fixture . ArrayOfArraysCollection . AsQueryable ( )
40- . Select ( x => x . Dictionary . Keys )
41- . ToList ( ) ;
42- } ) ;
43-
44- exception . Should ( ) . BeOfType < ExpressionNotSupportedException > ( ) ;
45- }
46-
47- [ Fact ]
48- public void Projecting_dictionary_keys_with_arrayOfDocs_should_throw ( )
49- {
50- var exception = Record . Exception ( ( ) =>
51- {
52- _ = Fixture . ArrayOfDocsCollection . AsQueryable ( )
53- . Select ( x => x . Dictionary . Keys )
54- . ToList ( ) ;
55- } ) ;
56-
57- exception . Should ( ) . BeOfType < ExpressionNotSupportedException > ( ) ;
58- }
59-
60- [ Fact ]
61- public void Projecting_dictionary_keys_with_document_should_throw ( )
62- {
63- var exception = Record . Exception ( ( ) =>
64- {
65- _ = Fixture . DocCollection . AsQueryable ( )
66- . Select ( x => x . Dictionary . Keys )
67- . ToList ( ) ;
68- } ) ;
69-
70- exception . Should ( ) . BeOfType < ExpressionNotSupportedException > ( ) ;
71- }
72-
73- [ Fact ]
74- public void Projecting_dictionary_values_with_arrayOfArrays_should_throw ( )
75- {
76- var exception = Record . Exception ( ( ) =>
77- {
78- _ = Fixture . ArrayOfArraysCollection . AsQueryable ( )
79- . Select ( x => x . Dictionary . Values )
80- . ToList ( ) ;
81- } ) ;
82-
83- exception . Should ( ) . BeOfType < ExpressionNotSupportedException > ( ) ;
84- }
85-
86- [ Fact ]
87- public void Projecting_dictionary_values_with_arrayOfDocs_should_throw ( )
88- {
89- var exception = Record . Exception ( ( ) =>
90- {
91- _ = Fixture . ArrayOfDocsCollection . AsQueryable ( )
92- . Select ( x => x . Dictionary . Values )
93- . ToList ( ) ;
94- } ) ;
95-
96- exception . Should ( ) . BeOfType < ExpressionNotSupportedException > ( ) ;
97- }
98-
99- [ Fact ]
100- public void Projecting_dictionary_values_with_document_should_throw ( )
101- {
102- var exception = Record . Exception ( ( ) =>
103- {
104- _ = Fixture . DocCollection . AsQueryable ( )
105- . Select ( x => x . Dictionary . Values )
106- . ToList ( ) ;
107- } ) ;
108-
109- exception . Should ( ) . BeOfType < ExpressionNotSupportedException > ( ) ;
110- }
111-
11233 [ Fact ]
11334 public void Select_DictionaryAsArrayOfArrays_All_should_work ( )
11435 {
@@ -148,7 +69,7 @@ public void Select_DictionaryAsArrayOfArrays_Average_should_work()
14869 . Select ( x => x . Dictionary . Values . Average ( ) ) ;
14970
15071 var stages = Translate ( collection , queryable ) ;
151- AssertStages ( stages , "{ $project : { _v : { $avg : { $map : { input : '$Dictionary', as : 'kvp', in : { $arrayElemAt : ['$$kvp', 1] } } } }, _id : 0 } }" ) ;
72+ AssertStages ( stages , "{ $project : { _v : { $avg : { $map : { input : { $map : { input : '$Dictionary', as : 'kvp', in : { k : { $arrayElemAt : ['$$kvp', 0] }, v : { $arrayElemAt : ['$$kvp', 1] } } } }, as : 'item', in : '$$item.v' } } }, _id : 0 } }" ) ;
15273
15374 var results = queryable . ToList ( ) ;
15475 results . Should ( ) . Equal ( 55.666666666666664 , 52.0 , 67.5 , 165.0 ) ;
@@ -283,7 +204,7 @@ public void Select_DictionaryAsArrayOfArrays_Max_should_work()
283204 . Select ( x => x . Dictionary . Values . Max ( ) ) ;
284205
285206 var stages = Translate ( collection , queryable ) ;
286- AssertStages ( stages , "{ $project : { _v : { $max : { $map : { input : '$Dictionary', as : 'kvp', in : { $arrayElemAt : ['$$kvp', 1] } } } }, _id : 0 } }" ) ;
207+ AssertStages ( stages , "{ $project : { _v : { $max : { $map : { input : { $map : { input : '$Dictionary', as : 'kvp', in : { k : { $arrayElemAt : ['$$kvp', 0] }, v : { $arrayElemAt : ['$$kvp', 1] } } } }, as : 'item', in : '$$item.v' } } }, _id : 0 } }" ) ;
287208
288209 var results = queryable . ToList ( ) ;
289210 results . Should ( ) . Equal ( 100 , 85 , 100 , 200 ) ;
@@ -632,7 +553,7 @@ public void Select_DictionaryAsDocument_Average_should_work()
632553 . Select ( x => x . Dictionary . Values . Average ( ) ) ;
633554
634555 var stages = Translate ( collection , queryable ) ;
635- AssertStages ( stages , "{ $project : { _v : { $avg : { $let : { vars : { this : { $objectToArray : '$Dictionary' } } , in : '$$this .v' } } }, _id : 0 } }" ) ;
556+ AssertStages ( stages , "{ $project : { _v : { $avg : { $map : { input : { $objectToArray : '$Dictionary' }, as : 'item' , in : '$$item .v' } } }, _id : 0 } }" ) ;
636557
637558 var results = queryable . ToList ( ) ;
638559 results . Should ( ) . Equal ( 55.666666666666664 , 52.0 , 67.5 , 165.0 ) ;
@@ -767,7 +688,7 @@ public void Select_DictionaryAsDocument_Max_should_work()
767688 . Select ( x => x . Dictionary . Values . Max ( ) ) ;
768689
769690 var stages = Translate ( collection , queryable ) ;
770- AssertStages ( stages , "{ $project : { _v : { $max : { $let : { vars : { this : { $objectToArray : '$Dictionary' } } , in : '$$this .v' } } }, _id : 0 } }" ) ;
691+ AssertStages ( stages , "{ $project : { _v : { $max : { $map : { input : { $objectToArray : '$Dictionary' }, as : 'item' , in : '$$item .v' } } }, _id : 0 } }" ) ;
771692
772693 var results = queryable . ToList ( ) ;
773694 results . Should ( ) . Equal ( 100 , 85 , 100 , 200 ) ;
@@ -1328,7 +1249,7 @@ public void Select_IDictionaryAsDocument_Average_should_work()
13281249 . Select ( x => x . DictionaryInterface . Values . Average ( ) ) ;
13291250
13301251 var stages = Translate ( collection , queryable ) ;
1331- AssertStages ( stages , "{ $project : { _v : { $avg : { $let : { vars : { this : { $objectToArray : '$DictionaryInterface' } } , in : '$$this .v' } } }, _id : 0 } }" ) ;
1252+ AssertStages ( stages , "{ $project : { _v : { $avg : { $map : { input : { $objectToArray : '$DictionaryInterface' }, as : 'kvp' , in : '$$kvp .v' } } }, _id : 0 } }" ) ;
13321253
13331254 var results = queryable . ToList ( ) ;
13341255 results . Should ( ) . Equal ( 55.666666666666664 , 52.0 , 67.5 , 165.0 ) ;
@@ -1448,7 +1369,7 @@ public void Select_IDictionaryAsDocument_Max_should_work()
14481369 . Select ( x => x . DictionaryInterface . Values . Max ( ) ) ;
14491370
14501371 var stages = Translate ( collection , queryable ) ;
1451- AssertStages ( stages , "{ $project : { _v : { $max : { $let : { vars : { this : { $objectToArray : '$DictionaryInterface' } } , in : '$$this .v' } } }, _id : 0 } }" ) ;
1372+ AssertStages ( stages , "{ $project : { _v : { $max : { $map : { input : { $objectToArray : '$DictionaryInterface' }, as : 'kvp' , in : '$$kvp .v' } } }, _id : 0 } }" ) ;
14521373
14531374 var results = queryable . ToList ( ) ;
14541375 results . Should ( ) . Equal ( 100 , 85 , 100 , 200 ) ;
0 commit comments