Changes between Version 3 and Version 4 of Ticket #29840


Ignore:
Timestamp:
Oct 11, 2018, 7:28:08 AM (6 years ago)
Author:
Simon Charette
Comment:

Hello there,

First str(queryset.query) is not guaranteed to return a valid SQL string; it's only meant to be used for debugging purpose.

Next it's not clear if Django is at fault unless you can provide a traceback and a reproduction case. From my understanding of your report it seems like you are experiencing these errors when manually running the debugging SQL provided by str(queryset.query) so I'm going to close as invalid for now.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #29840

    • Property Status assignedclosed
    • Property Resolutioninvalid
  • Ticket #29840 – Description

    v3 v4  
    11I have a django query which compares datetime like this -
    22
    3     filters = {'order_created_on__gte':'2018-10-10'}
    4     queryset = model.objects.filter(**filters)
    5     query = str(queryset.query)
     3{{{#!python
     4filters = {'order_created_on__gte':'2018-10-10'}
     5queryset = model.objects.filter(**filters)
     6query = str(queryset.query)
     7}}}
    68
    79It creates a query  - select ... where order_created_on >= 2018-10-10 00:00:00
     
    1315Now I actually tried the following ways, but all queries give the same text in the db query
    1416
    15     filters = {'order_created_on__gte':datetime(2018-10-10)}
    16     filters = {'order_created_on__year__gte':2018, 'order_created_on__month__gte':10, 'order_created_on__day__gte':10}
     17{{{#!python
     18filters = {'order_created_on__gte':datetime(2018-10-10)}
     19filters = {'order_created_on__year__gte':2018, 'order_created_on__month__gte':10, 'order_created_on__day__gte':10}
     20}}}
    1721
    1822Also used the range filter, all of the above insert this text in the final query -
    1923
    20     where order_created_on >= 2018-10-10 00:00:00
     24{{{#!sql
     25where order_created_on >= 2018-10-10 00:00:00
     26}}}
    2127
    2228Updating the time zone too didnt have any effect rather than just removing a +5:30 from the query.
Back to Top