#29884: QuerySet.filter() with TruncBase functions not working as expected when
USE_TZ= True
-------------------------------------+-------------------------------------
     Reporter:  slide333333          |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Dan Davis):

 * owner:  Dan Davis => (none)
 * status:  assigned => new
 * needs_tests:  1 => 0


Comment:

 Replying to [comment:9 Tim Graham]:
 > I don't expect this would require backend-specific tests. The queries
 results should be the same across all databases, shouldn't they? I haven't
 looking into this issue to say whether or not there's a bug here.

 This would be fixed in each backend separately, because the method to
 truncate a datetime is delegated to each backend separately.
 Nevertheless, since the unit tests are run against a specific backend, by
 default sqlite3, the test can be in
 `tests/db_functions/datetime/test_extract_trunc.py`.

 Pull request https://github.com/django/django/pull/10611 provides a
 failing test for the filtering case.   It isn't ready, but anyone else can
 see the diff.

 I've run this against sqlite3 and also against postgresql like this:
 {{{
 ./runtests.py --settings postgresql_settings
 db_functions.datetime.test_extract_trunc
 }}}

 I'm out of this one - I would want someone with more experience in the
 project to decide whether the single ticket should be fixed for all
 backends or just for PostgreSQL.

 One thing I notice is that make_aware is surprisingly not the same thing
 as adding the tzinfo to the datetime in the first place.   The following
 raises:

 {{{
 from datetime import datetime
 import pytz
 from django.utils.timezone import make_aware

 euberlin = pytz.timezone('Europe/Berlin')s a
 dt1 = datetime(2018, 10, 24, tzinfo=euberlin)
 dt2 = make_aware(datetime(2018, 10, 24))
 assert dt1 == dt2
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29884#comment:10>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.bc6f2d7f8414ced94e4ebb1e1c7b4121%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to