-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Removed unreachable condition in TruncBase.convert_value() #19461
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
base: main
Are you sure you want to change the base?
Conversation
elif isinstance(value, datetime): | ||
if value is None: | ||
pass | ||
elif isinstance(self.output_field, DateField): | ||
if isinstance(self.output_field, DateField): | ||
value = value.date() | ||
elif isinstance(self.output_field, TimeField): | ||
value = value.time() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this whole branch is uncovered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on the database, I think. This may merit further investigation to clarify, but at least the first branch is run on PostgreSQL: https://djangoci.com/job/django-coverage-postgis/HTML_20Coverage_20Report/z_710479c84428724c_datetime_py.html#t357
I needed to customize the entire method on MongoDB, so I'm thinking about how I can add some hook in order to remove that monkeypatch in a future version of Django.
mongodb/django-mongodb-backend@85f02ef#diff-9bb9fc083062f41644e45753aef34a4c8381d250fed38ad42b0332ef39041f23R203-R227
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks didn't know we had this coverage job as well.
So it's not run on SQLite because (datetime|date|time)_trunc_sql
run specialized Python functions that already return the proper type.
The first branch is implicitly tested by these usage of the __date
transform in aggregation tests
django/tests/aggregation/tests.py
Line 2216 in 825ddda
"original_opening__date", |
But we don't appear to have the equivalent coverage for __time
Incorrectly added in 34d6bce.
f4e7336
to
cbe5b92
Compare
Incorrectly added in 34d6bce.