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

Fixed deserialization of datetime.date fields #1914

Merged

Conversation

miguelgrinberg
Copy link
Collaborator

Fixes #1913

@miguelgrinberg miguelgrinberg force-pushed the date-deserialization-fix branch 2 times, most recently from 64257a5 to f512f1e Compare September 13, 2024 11:25
assert dt == f._deserialize(dt.isoformat())

d = date.today()
assert datetime.combine(d, time()) == f._deserialize(d.isoformat())
Copy link
Member

Choose a reason for hiding this comment

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

It took me a while to understand that this wasn't time.time() but converting to a datetime at midnight.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had a passing thought that datetime.time() might be confused with time.time() as well. Maybe I should namespace it here.

@miguelgrinberg miguelgrinberg merged commit 6db7e9d into elastic:main Sep 13, 2024
16 checks passed
@miguelgrinberg miguelgrinberg deleted the date-deserialization-fix branch September 13, 2024 11:45
@miguelgrinberg miguelgrinberg added the backport 8.x Backport to 8.x label Sep 13, 2024
github-actions bot pushed a commit that referenced this pull request Sep 13, 2024
miguelgrinberg added a commit that referenced this pull request Sep 13, 2024
Fixes #1913

(cherry picked from commit 6db7e9d)

Co-authored-by: Miguel Grinberg <miguel.grinberg@gmail.com>
miguelgrinberg added a commit to miguelgrinberg/elasticsearch-dsl-py that referenced this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 8.x Backport to 8.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dates get casted to datetimes on retrieved objects, causing parsing errors during updates
2 participants