Skip to content

Commit fc84fec

Browse files
authored
CDRIVER-3974 Append Versioned API options to all commands (#792)
1 parent 5cd215b commit fc84fec

File tree

5 files changed

+32
-230
lines changed

5 files changed

+32
-230
lines changed

src/libmongoc/src/mongoc/mongoc-cmd.c

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -785,22 +785,6 @@ _is_retryable_read (const mongoc_cmd_parts_t *parts,
785785
}
786786

787787

788-
static bool
789-
_txn_in_progress (mongoc_cmd_parts_t *parts)
790-
{
791-
mongoc_client_session_t *cs;
792-
793-
cs = parts->prohibit_lsid ? NULL : parts->assembled.session;
794-
if (!cs) {
795-
return false;
796-
}
797-
798-
return (_mongoc_client_session_txn_in_progress (cs)
799-
/* commitTransaction and abortTransaction count as in progress, too. */
800-
|| parts->assembled.is_txn_finish);
801-
}
802-
803-
804788
/*
805789
*--------------------------------------------------------------------------
806790
*
@@ -988,13 +972,10 @@ mongoc_cmd_parts_assemble (mongoc_cmd_parts_t *parts,
988972
&parts->assembled_body, "$clusterTime", 12, cluster_time);
989973
}
990974

991-
/* Add versioned server api, if it is set. Do not add api if we are
992-
sending a getmore, or if we are in a transaction. */
975+
/* Add versioned server api, if it is set. */
993976
if (parts->client->api) {
994-
if (!is_get_more && !_txn_in_progress (parts)) {
995-
_mongoc_cmd_append_server_api (&parts->assembled_body,
996-
parts->client->api);
997-
}
977+
_mongoc_cmd_append_server_api (&parts->assembled_body,
978+
parts->client->api);
998979
}
999980

1000981
if (!is_get_more) {

src/libmongoc/tests/json/versioned_api/crud-api-version-1-strict.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@
651651
]
652652
},
653653
{
654-
"description": "find command with declared API version appends to the command, but getMore does not",
654+
"description": "find and getMore append API version",
655655
"operations": [
656656
{
657657
"name": "find",
@@ -712,14 +712,10 @@
712712
"long"
713713
]
714714
},
715-
"apiVersion": {
716-
"$$exists": false
717-
},
718-
"apiStrict": {
719-
"$$exists": false
720-
},
715+
"apiVersion": "1",
716+
"apiStrict": true,
721717
"apiDeprecationErrors": {
722-
"$$exists": false
718+
"$$unsetOrMatches": false
723719
}
724720
}
725721
}
@@ -1111,4 +1107,4 @@
11111107
]
11121108
}
11131109
]
1114-
}
1110+
}

src/libmongoc/tests/json/versioned_api/crud-api-version-1.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@
599599
]
600600
},
601601
{
602-
"description": "estimatedDocumentCount appends declared API version",
602+
"description": "estimatedDocumentCount appends declared API version on 4.9.0 or greater",
603603
"operations": [
604604
{
605605
"name": "estimatedDocumentCount",
@@ -643,7 +643,7 @@
643643
]
644644
},
645645
{
646-
"description": "find command with declared API version appends to the command, but getMore does not",
646+
"description": "find and getMore append API version",
647647
"operations": [
648648
{
649649
"name": "find",
@@ -704,15 +704,11 @@
704704
"long"
705705
]
706706
},
707-
"apiVersion": {
708-
"$$exists": false
709-
},
707+
"apiVersion": "1",
710708
"apiStrict": {
711-
"$$exists": false
709+
"$$unsetOrMatches": false
712710
},
713-
"apiDeprecationErrors": {
714-
"$$exists": false
715-
}
711+
"apiDeprecationErrors": true
716712
}
717713
}
718714
}
@@ -1103,4 +1099,4 @@
11031099
]
11041100
}
11051101
]
1106-
}
1102+
}

src/libmongoc/tests/json/versioned_api/test-commands-deprecation-errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@
7171
]
7272
}
7373
]
74-
}
74+
}

0 commit comments

Comments
 (0)