#30575: Union of TruncBase annotations with different tzinfo apply
`convert_value`
of last tzinfo.
-------------------------------------+-------------------------------------
Reporter: Jurgis Pralgauskis | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | worksforme
Keywords: timezone, | Triage Stage:
TruncBase, Union, PostgreSQL | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):
* status: new => closed
* version: 1.11 => master
* resolution: => worksforme
Comment:
Thanks for the report, however ticket description is not correct. Django
uses `tzinfo` properly in your use case:
{{{
SELECT
...
DATE_TRUNC('second', "ticket_30575_message"."timestamp" AT TIME ZONE
'UTC') AS "trunc_local_time",
UTC AS "tzname"
FROM "ticket_30575_message" WHERE "ticket_30575_message"."timezone" = UTC
UNION
SELECT
...
DATE_TRUNC('second', "ticket_30575_message"."timestamp" AT TIME ZONE
'America/Los_Angeles') AS "trunc_local_time",
America/Los_Angeles AS "tzname"
FROM "ticket_30575_message" WHERE "ticket_30575_message"."timezone" = UTC)
}}}
i.e. `UTC` in a `qs1` and `America/Los_Angeles` in qs2. You can add
`tzname` to you queryset (e.g. `tzname=Value(tzname,
output_field=CharField())`) to check that everything works properly:
{{{
>>> for x in result:
>>> print(x.timestamp, x.trunc_local_time, x.tzname)
2019-06-18 10:07:04.111245+00:00 2019-06-18 03:07:04+00:00
America/Los_Angeles
2019-06-18 10:07:04.111245+00:00 2019-06-18 10:07:04+00:00 UTC
}}}
Closing per TicketClosingReasons/UseSupportChannels.
--
Ticket URL: <https://code.djangoproject.com/ticket/30575#comment:5>
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/061.e79539260a85c2a3776af06fb865b9a1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.