Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#33279 closed Bug (fixed)

Time zones with minus in names are incorrectly converted.

Reported by: yakimka Owned by: Can Sarıgöl
Component: Database layer (models, ORM) Version: 3.2
Severity: Normal Keywords:
Cc: Can Sarıgöl, Carlton Gibson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Maybe I do something wrong, but I ran into a problem:

In [1]: import zoneinfo

In [2]: import datetime

In [3]: with timezone.override(zoneinfo.ZoneInfo('Asia/Ust-Nera')):
   ...:     SomeModel.objects.filter(date__date=datetime.datetime.now().date()).only('id').first()
   ...: 
SELECT "some_model"."id"
  FROM "some_model"
 WHERE ("some_model"."date" AT TIME ZONE 'Asia/Ust+Nera')::date = '2021-11-10'::date
 ORDER BY "some_model"."id" ASC
 LIMIT 1

Execution time: 0.003478s [Database: default]
---------------------------------------------------------------------------
InvalidParameterValue                     Traceback (most recent call last)
/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py in _execute(self, sql, params, *ignored_wrapper_args)
     83             else:
---> 84                 return self.cursor.execute(sql, params)
     85 

InvalidParameterValue: time zone "Asia/Ust+Nera" not recognized

Timezone "Asia/Ust-Nera" supported by psql:

SELECT name FROM pg_timezone_names where name = 'Asia/Ust-Nera';

Reproduced on Postgresql 11 and 12

Change History (10)

comment:1 by Mariusz Felisiak, 3 years ago

Cc: Can Sarıgöl Carlton Gibson added
Summary: time zone with dash in name not recognizedTime zones with minus in names are incorrectly converted.
Triage Stage: UnreviewedAccepted

Thanks for the report. Time zones with the minus in names are incorrectly converted:

  • to -Nera on MySQL and Oracle,
  • to Asia/Ust+Nera on PostgreSQL,
  • to Asia/Ust and +Nera offset on SQLite.

Regression in fde9b7d35e4e185903cc14aa587ca870037941b1.

comment:2 by Can Sarıgöl, 3 years ago

Owner: changed from nobody to Can Sarıgöl
Status: newassigned

comment:3 by Can Sarıgöl, 3 years ago

Has patch: set

comment:4 by Mariusz Felisiak, 3 years ago

Needs tests: set
Patch needs improvement: set

comment:5 by Can Sarıgöl, 3 years ago

Needs tests: unset
Patch needs improvement: unset

comment:6 by Mariusz Felisiak, 3 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 661316b0:

Fixed #33279 -- Fixed handling time zones with "-" sign in names.

Thanks yakimka for the report.

Regression in fde9b7d35e4e185903cc14aa587ca870037941b1.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In d54aa49a:

[4.0.x] Fixed #33279 -- Fixed handling time zones with "-" sign in names.

Thanks yakimka for the report.

Regression in fde9b7d35e4e185903cc14aa587ca870037941b1.

Backport of 661316b066923493ff91d6d2aa92e463f595a6b1 from main.

comment:9 by yakimka, 3 years ago

This fix was not added to version 3.2.10 by mistake?

in reply to:  9 comment:10 by Mariusz Felisiak, 3 years ago

Replying to yakimka:

This fix was not added to version 3.2.10 by mistake?

It's a regression in Django 3.0, per our backporting policy this means it doesn't qualify for a backport to 3.2.x anymore. See Django’s release process for more details.

Note: See TracTickets for help on using tickets.
Back to Top