tortoise / tortoise/tortoise-orm
timezone bug
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Describe the bug
When I set the time zone to the above, I got +16, which caused an error in MySQL
To Reproduce
'timezone': 'America/Los_Angeles'
Expected behavior
A clear and concise description of what you expected to happen.
Additional context
Traceback (most recent call last):
File "/venv/lib/python3.11/site-packages/tortoise/backends/mysql/client.py", line 129, in create_connection
await cursor.execute(f"SET SESSION time_zone='{tz}';")
File "asyncmy/cursors.pyx", line 179, in execute
File "asyncmy/cursors.pyx", line 364, in _query
File "asyncmy/connection.pyx", line 494, in query
File "asyncmy/connection.pyx", line 682, in _read_query_result
File "asyncmy/connection.pyx", line 1069, in read
File "asyncmy/connection.pyx", line 644, in read_packet
File "asyncmy/protocol.pyx", line 190, in asyncmy.protocol.MysqlPacket.raise_for_error
File "asyncmy/protocol.pyx", line 194, in asyncmy.protocol.MysqlPacket.raise_for_error
File "asyncmy/errors.pyx", line 128, in asyncmy.errors.raise_mysql_exception
File "asyncmy/errors.pyx", line 137, in asyncmy.errors.raise_mysql_exception
asyncmy.errors.OperationalError: (1298, "Unknown or incorrect time zone: '+16:00'")
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MySQL connection setup in tortoise/backends/mysql/client.py, especially the timezone value passed to SET SESSION time_zone. Reproduce the reported America/Los_Angeles configuration and inspect how it becomes '+16:00'. Done means the configured timezone is accepted by MySQL without the reported OperationalError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, python
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100