Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shared: add UTCDateTime column type #179

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

utnapischtim
Copy link
Contributor

  • with that it is possible to solve the datetime.utcnow DeprecationWarnings

* with that it is possible to solve the datetime.utcnow DeprecationWarnings
def process_bind_param(self, value, dialect):
"""Process value storing into database."""
if isinstance(value, datetime):
return value.replace(tzinfo=None)
Copy link
Member

Choose a reason for hiding this comment

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

minor: I think here we should also check that value.tzinfo in (None, timezone.utc), and only in that case proceed. I would even go as far as raising an exception if it's not the case, since implicitly dropping the timezone info (or converting from local to UTC) is the behavior we want to avoid.

Needs to be tested in a couple of complex modules first (e.g. invenio-rdm-records), but I have a feeling that it'll also help us to catch some datetime-related bugs :)

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