Skip to content

Conversation

bcwarner
Copy link
Contributor

Added to the FAQ, and tweaked another doc. Will have to be tweaked again after renaming DatetimeConversionOpts.

doc/faq.rst Outdated
the default behavior and
:attr:`~bson.datetime_ms.DatetimeConversionOpts.DATETIME_MS`, returning
:class:`~datetime.datetime`s when possible, and
:class:`~bson.datetime_ms.DatetimeMS` when representations are out-of-range.
Copy link
Member

Choose a reason for hiding this comment

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

Rather than duplicating the behavior of each DatetimeConversionOpts, what if we just suggest using DATETIME_AUTO and then link to the DatetimeConversionOpts example page for the rest?

@bcwarner
Copy link
Contributor Author

bcwarner commented Jul 29, 2022

There's a broken link to DatetimeMS which I think is contingent on PYTHON-3377 being fixed.

Edit: fixed

doc/faq.rst Outdated
@@ -502,6 +518,7 @@ just that field::

>>> cur = coll.find({}, projection={'dt': False})


Copy link
Member

Choose a reason for hiding this comment

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

extra space?

@bcwarner
Copy link
Contributor Author

Started making edits to datetime.rst before I read PYTHON-3378 was also a ticket, so I'm going to keep both here.

@bcwarner bcwarner changed the title PYTHON-3376 Update FAQ about OverflowError when decoding out of range datetimes PYTHON-3376/3378 Update FAQ about OverflowError when decoding out of range datetimes Jul 29, 2022
doc/faq.rst Outdated
For other options, please refer to
:class:`~bson.codec_options.DatetimeConversionOpts`.

If we need to use the default decoding behavior with datetimes not supported by
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest changing from "If we need to use the default decoding behavior ... filter out documents ..." -> "Another option that does not involve setting datetime_conversion is to to filter out documents ..."

Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

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

LGTM assuming the doctests pass.

>>> decode(x, codec_options=codec_clamp)
{'x': datetime.datetime(1970, 1, 1, 0, 0)}
>>> decode(x, codec_options=codec_clamp)
{'x': DatetimeMS(-2**62)}
Copy link
Member

Choose a reason for hiding this comment

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

Should be datetime.datetime(1, 1, 1, 0, 0) (min)?

@ShaneHarvey ShaneHarvey changed the title PYTHON-3376/3378 Update FAQ about OverflowError when decoding out of range datetimes PYTHON-3376/PYTHON-3378 Update FAQ about OverflowError when decoding out of range datetimes Aug 3, 2022
@ShaneHarvey
Copy link
Member

FYI you can run the doctests locally by running python setup.py doc -t with single mongod server.

@bcwarner bcwarner merged commit 92a6fa7 into mongodb:master Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants