Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bson/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ class UuidRepresentation:
.. versionadded:: 4.0
"""

SENSITIVE_SUBTYPE = 8
"""BSON binary subtype for sensitive data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are users ever expected to use this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec doesn't mention it, but other drivers expose these constants, e.g. https://github.com/mongodb/mongo-go-driver/blob/4acd55139b846e6bfdfe316770a5b1b646d5ff96/bson/types.go#L47.


.. versionadded:: 4.5
"""


USER_DEFINED_SUBTYPE = 128
"""BSON binary subtype for any user defined structure.
"""
Expand Down
1 change: 1 addition & 0 deletions doc/api/bson/binary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
.. autodata:: CSHARP_LEGACY
.. autodata:: MD5_SUBTYPE
.. autodata:: COLUMN_SUBTYPE
.. autodata:: SENSITIVE_SUBTYPE
.. autodata:: USER_DEFINED_SUBTYPE

.. autoclass:: UuidRepresentation
Expand Down
5 changes: 5 additions & 0 deletions test/bson_corpus/binary.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
"canonical_bson": "1D000000057800100000000773FFD26444B34C6990E8E7D1DFC035D400",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"07\"}}}"
},
{
"description": "subtype 0x08",
"canonical_bson": "1D000000057800100000000873FFD26444B34C6990E8E7D1DFC035D400",
"canonical_extjson": "{\"x\" : { \"$binary\" : {\"base64\" : \"c//SZESzTGmQ6OfR38A11A==\", \"subType\" : \"08\"}}}"
},
{
"description": "subtype 0x80",
"canonical_bson": "0F0000000578000200000080FFFF00",
Expand Down