#28410: query filter on date portion of datetime creates wrong parameters for 
mysql
CONVERT_TZ function and returns no results
-------------------------------------+-------------------------------------
     Reporter:  donaldinho           |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.11
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  timezone date        |             Triage Stage:
  filter                             |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by donaldinho:

Old description:

> I am setting the timezone
>
> {{{
> tz = timezone.get_fixed_timezone(-300)
> timezone.activate(tz)
> }}}
>
> then I apply the filter. search_date is just a string submitted by the
> client
>
> {{{
> matches = query.filter(startDateTime__date=datetime.strptime(search_date,
> '%Y-%m-%d').date())
> }}}
>
> the where clause that is produced is
> {{{
> DATE(CONVERT_TZ(`central_soccer_match`.`startDateTime`, 'UTC', '-0500'))
> = '2017-07-18'
> }}}
>
> where as it should be
>
> {{{
> DATE(CONVERT_TZ(`central_soccer_match`.`startDateTime`, 'UTC', '-05:00'))
> = '2017-07-18'
> }}}
>
> note the colon in the timezone we are converting to.

New description:

 I am setting the timezone

 {{{
 tz = timezone.get_fixed_timezone(-300)
 timezone.activate(tz)
 }}}

 then I apply the filter. search_date is just a string submitted by the
 client

 {{{
 matches = query.filter(startDateTime__date=datetime.strptime(search_date,
 '%Y-%m-%d').date())
 }}}

 the where clause that is produced is
 {{{
 DATE(CONVERT_TZ(`match`.`startDateTime`, 'UTC', '-0500')) = '2017-07-18'
 }}}

 where as it should be

 {{{
 DATE(CONVERT_TZ(match`.`startDateTime`, 'UTC', '-05:00')) = '2017-07-18'
 }}}

 note the colon in the timezone we are converting to.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28410#comment:1>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.d37216582b382e119914c5f9e1eb299c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to