@@ -575,49 +575,28 @@ test_maxtimems (void)
575
575
576
576
577
577
static void
578
- test_index_spec_modifiers (void )
578
+ test_comment (void )
579
579
{
580
- /* don't include $max, it needs a slightly different argument to succeed */
581
- const char * modifiers [] = {
582
- "hint" ,
583
- "min" ,
584
- };
585
-
586
- const char * mod ;
587
- size_t i ;
588
- char * query ;
589
- char * find_command ;
590
580
test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT ;
591
-
592
- test_data .expected_result = test_data .docs = "[{'_id': 1}]" ;
593
-
594
- for (i = 0 ; i < sizeof (modifiers ) / sizeof (const char * ); i ++ ) {
595
- mod = modifiers [i ];
596
- query = bson_strdup_printf ("{'$query': {}, '$%s': {'_id': 1}}" , mod );
597
-
598
- /* find command has same modifier, without the $-prefix */
599
- find_command = bson_strdup_printf (
600
- "{'find': 'collection', 'filter': {}, '%s': {'_id': 1}}" , mod );
601
-
602
- test_data .expected_op_query = test_data .query_input = query ;
603
- test_data .expected_find_command = find_command ;
604
- _test_collection_find (& test_data );
605
-
606
- bson_free (query );
607
- bson_free (find_command );
608
- }
581
+ test_data .docs = "[{'_id': 1}]" ;
582
+ test_data .query_input = "{'$query': {}, '$comment': 'hi'}" ;
583
+ test_data .expected_op_query = test_data .query_input ;
584
+ test_data .expected_find_command =
585
+ "{'find': 'collection', 'filter': {}, 'comment': 'hi'}" ;
586
+ test_data .expected_result = "[{'_id': 1}]" ;
587
+ _test_collection_find (& test_data );
609
588
}
610
589
611
590
612
591
static void
613
- test_comment (void )
592
+ test_hint (void )
614
593
{
615
594
test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT ;
616
595
test_data .docs = "[{'_id': 1}]" ;
617
- test_data .query_input = "{'$query': {}, '$comment ': 'hi' }" ;
596
+ test_data .query_input = "{'$query': {}, '$hint ': { '_id': 1 } }" ;
618
597
test_data .expected_op_query = test_data .query_input ;
619
598
test_data .expected_find_command =
620
- "{'find': 'collection', 'filter': {}, 'comment ': 'hi' }" ;
599
+ "{'find': 'collection', 'filter': {}, 'hint ': { '_id': 1 } }" ;
621
600
test_data .expected_result = "[{'_id': 1}]" ;
622
601
_test_collection_find (& test_data );
623
602
}
@@ -628,10 +607,29 @@ test_max (void)
628
607
{
629
608
test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT ;
630
609
test_data .docs = "[{'_id': 1}]" ;
631
- test_data .query_input = "{'$query': {}, '$max': {'_id': 100}}" ;
610
+ /* MongoDB 4.2 requires that max/min also use hint */
611
+ test_data .query_input =
612
+ "{'$query': {}, '$max': {'_id': 100}, '$hint': { '_id': 1 }}" ;
632
613
test_data .expected_op_query = test_data .query_input ;
633
614
test_data .expected_find_command =
634
- "{'find': 'collection', 'filter': {}, 'max': {'_id': 100}}" ;
615
+ "{'find': 'collection', 'filter': {}, "
616
+ "'max': {'_id': 100}, 'hint': { '_id': 1 }}" ;
617
+ test_data .expected_result = "[{'_id': 1}]" ;
618
+ _test_collection_find (& test_data );
619
+ }
620
+
621
+
622
+ static void
623
+ test_min (void )
624
+ {
625
+ test_collection_find_t test_data = TEST_COLLECTION_FIND_INIT ;
626
+ test_data .docs = "[{'_id': 1}]" ;
627
+ /* MongoDB 4.2 requires that max/min also use hint */
628
+ test_data .query_input =
629
+ "{'$query': {}, '$min': {'_id': 1}, '$hint': { '_id': 1 }}" ;
630
+ test_data .expected_op_query = test_data .query_input ;
631
+ test_data .expected_find_command = "{'find': 'collection', 'filter': {}, "
632
+ "'min': {'_id': 1}, 'hint': { '_id': 1 }}" ;
635
633
test_data .expected_result = "[{'_id': 1}]" ;
636
634
_test_collection_find (& test_data );
637
635
}
@@ -1221,11 +1219,10 @@ test_collection_find_install (TestSuite *suite)
1221
1219
test_framework_skip_if_max_wire_version_more_than_6 );
1222
1220
TestSuite_AddLive (
1223
1221
suite , "/Collection/find/modifiers/maxtimems" , test_maxtimems );
1224
- TestSuite_AddLive (suite ,
1225
- "/Collection/find/modifiers/index_spec" ,
1226
- test_index_spec_modifiers );
1227
1222
TestSuite_AddLive (suite , "/Collection/find/comment" , test_comment );
1223
+ TestSuite_AddLive (suite , "/Collection/find/hint" , test_hint );
1228
1224
TestSuite_AddLive (suite , "/Collection/find/max" , test_max );
1225
+ TestSuite_AddLive (suite , "/Collection/find/min" , test_min );
1229
1226
TestSuite_AddLive (suite , "/Collection/find/modifiers/bool" , test_snapshot );
1230
1227
TestSuite_AddLive (suite , "/Collection/find/showdiskloc" , test_diskloc );
1231
1228
TestSuite_AddLive (suite , "/Collection/find/returnkey" , test_returnkey );
0 commit comments