Skip to content

Commit b1b5a7f

Browse files
authored
DRIVERS-2865: Require drivers to always send out bypassDocumentValidation (#1703)
1 parent 38cbbce commit b1b5a7f

File tree

4 files changed

+724
-20
lines changed

4 files changed

+724
-20
lines changed

source/crud/bulk-write.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -897,19 +897,6 @@ recording the summary counts. We expect that most users are not interested in th
897897
and that most users will rely on defaults, so `verboseResults` defaults to `false` to improve performance in the common
898898
case.
899899

900-
### Why should drivers send `bypassDocumentValidation: false` for `bulkWrite`?
901-
902-
[DRIVERS-450](https://jira.mongodb.org/browse/DRIVERS-450) introduced a requirement that drivers only send a value for
903-
`bypassDocumentValidation` on write commands if it was specified as true. The original motivation for this change is not
904-
documented. This specification requires that drivers send `bypassDocumentValidation` in the `bulkWrite` command if it is
905-
set by the user in `BulkWriteOptions`, regardless of its value.
906-
907-
Explicitly defining `bypassDocumentValidation: false` aligns with the server's default to perform schema validation and
908-
thus has no effect. However, checking the value of an option that the user specified and omitting it from the command
909-
document if it matches the server's default creates unnecessary work for drivers. Always sending the user's specified
910-
value also safeguards against the unlikely event that the server changes the default value for
911-
`bypassDocumentValidation` in the future.
912-
913900
### Why is providing access to the raw server response when a command error occurs required?
914901

915902
This allows users to access new error fields that the server may add in the future without needing to upgrade their

source/crud/crud.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ class BulkWriteOptions {
924924
/**
925925
* If true, allows the write to opt-out of document level validation.
926926
*
927-
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
927+
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
928928
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
929929
* For unacknowledged writes using OP_INSERT, OP_UPDATE, or OP_DELETE, the driver MUST raise an error if the caller explicitly provides a value.
930930
*/
@@ -959,7 +959,7 @@ class InsertOneOptions {
959959
/**
960960
* If true, allows the write to opt-out of document level validation.
961961
*
962-
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
962+
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
963963
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
964964
* For unacknowledged writes using OP_INSERT, the driver MUST raise an error if the caller explicitly provides a value.
965965
*/
@@ -981,7 +981,7 @@ class InsertManyOptions {
981981
/**
982982
* If true, allows the write to opt-out of document level validation.
983983
*
984-
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
984+
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
985985
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
986986
* For unacknowledged writes using OP_INSERT, the driver MUST raise an error if the caller explicitly provides a value.
987987
*/
@@ -1021,7 +1021,7 @@ class UpdateOptions {
10211021
/**
10221022
* If true, allows the write to opt-out of document level validation.
10231023
*
1024-
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
1024+
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
10251025
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
10261026
* For unacknowledged writes using OP_UPDATE, the driver MUST raise an error if the caller explicitly provides a value.
10271027
*/
@@ -1101,7 +1101,7 @@ class ReplaceOptions {
11011101
/**
11021102
* If true, allows the write to opt-out of document level validation.
11031103
*
1104-
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
1104+
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
11051105
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
11061106
* For unacknowledged writes using OP_UPDATE, the driver MUST raise an error if the caller explicitly provides a value.
11071107
*/
@@ -1983,7 +1983,7 @@ class FindOneAndReplaceOptions {
19831983
/**
19841984
* If true, allows the write to opt-out of document level validation.
19851985
*
1986-
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
1986+
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
19871987
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
19881988
*/
19891989
bypassDocumentValidation: Optional<Boolean>;
@@ -2101,7 +2101,7 @@ class FindOneAndUpdateOptions {
21012101
/**
21022102
* If true, allows the write to opt-out of document level validation.
21032103
*
2104-
* This option is sent only if the caller explicitly provides a true value. The default is to not send a value.
2104+
* This option is sent only if the caller explicitly provides a value. The default is to not send a value.
21052105
* For servers < 3.2, this option is ignored and not sent as document validation is not available.
21062106
*/
21072107
bypassDocumentValidation: Optional<Boolean>;
@@ -2486,6 +2486,8 @@ aforementioned allowance in the SemVer spec.
24862486
24872487
## Changelog
24882488
2489+
- 2024-11-04: Always send a value for `bypassDocumentValidation` if it was specified.
2490+
24892491
- 2024-10-30: Document query limitations in `countDocuments`.
24902492
24912493
- 2024-10-28: Clarified that generated identifiers should be prepended to documents.

0 commit comments

Comments
 (0)