diff --git a/doc/faq.rst b/doc/faq.rst index 800c41b70..886508b37 100644 --- a/doc/faq.rst +++ b/doc/faq.rst @@ -283,11 +283,15 @@ timeouts can be turned off entirely. Pass ``no_cursor_timeout=True`` to How can I store :mod:`decimal.Decimal` instances? ------------------------------------------------- -MongoDB only supports IEEE 754 floating points - the same as the -Python float type. The only way PyMongo could store Decimal instances -would be to convert them to this standard, so you'd really only be -storing floats anyway - we force users to do this conversion -explicitly so that they are aware that it is happening. + +PyMongo >= 3.4 supports the Decimal128 BSON type introduced in MongoDB 3.4. +See :mod:`~bson.decimal128` for more information. + +MongoDB <= 3.2 only supports IEEE 754 floating points - the same as the +Python float type. The only way PyMongo could store Decimal instances to +these versions of MongoDB would be to convert them to this standard, so +you'd really only be storing floats anyway - we force users to do this +conversion explicitly so that they are aware that it is happening. I'm saving ``9.99`` but when I query my document contains ``9.9900000000000002`` - what's going on here? -------------------------------------------------------------------------------------------------------- diff --git a/test/test_decimal128.py b/test/test_decimal128.py index 4e5ef815a..3ddf0a8c3 100644 --- a/test/test_decimal128.py +++ b/test/test_decimal128.py @@ -35,6 +35,10 @@ from test import client_context, unittest class TestDecimal128(unittest.TestCase): def test_round_trip(self): + if not client_context.version.at_least(3, 3, 6): + raise unittest.SkipTest( + 'Round trip test requires MongoDB >= 3.3.6') + coll = client_context.client.pymongo_test.test coll.drop()