Skip to content

Commit fd9b9e1

Browse files
committed
Address review
1 parent 7b28e31 commit fd9b9e1

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

bson/decimal128.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@
6464
class DecimalEncoder(TypeEncoder):
6565
"""Converts Python :class:`decimal.Decimal` to BSON :class:`Decimal128`.
6666
67-
.. warning:: When converting BSON data types to and from built-in data types,
68-
the possibility of data loss is always present due to mismatches in underlying implementations.
67+
For example::
68+
opts = CodecOptions(type_registry=TypeRegistry([DecimalEncoder()]))
69+
bson.encode({"d": decimal.Decimal('1.0')}, codec_options=opts)
6970
7071
.. versionadded:: 4.15"""
7172

@@ -80,8 +81,9 @@ def transform_python(self, value: Any) -> Decimal128:
8081
class DecimalDecoder(TypeDecoder):
8182
"""Converts BSON :class:`Decimal128` to Python :class:`decimal.Decimal`.
8283
83-
.. warning:: When converting BSON data types to and from built-in data types,
84-
the possibility of data loss is always present due to mismatches in underlying implementations.
84+
For example::
85+
opts = CodecOptions(type_registry=TypeRegistry([DecimalDecoder()]))
86+
bson.decode(b'\x18\x00\x00\x00\x13d\x00\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>0\x00', codec_options=opts)
8587
8688
.. versionadded:: 4.15"""
8789

doc/changelog.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ Changelog
22
=========
33
Changes in Version 4.15.0 (XXXX/XX/XX)
44
--------------------------------------
5-
.. warning:: When converting BSON data types to and from built-in data types, the possibility of data loss is always present
6-
due to mismatches in underlying implementations.
7-
85
PyMongo 4.15 brings a number of changes including:
96

107
- Added :class:`bson.decimal128.DecimalEncoder` and :class:`bson.decimal128.DecimalDecoder`

0 commit comments

Comments
 (0)