MagicStack / MagicStack/asyncpg
Database timezone ignored for timestamptz
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 8.1k
- Fork
- 468
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
* **asyncpg version**: 0.27.0
* **PostgreSQL version**: 15.1
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?**: local
* **Python version**: 3.10.9
* **Platform**: Linux
* **Do you use pgbouncer?**: no
* **Did you install asyncpg with pip?**: no
* **If you built asyncpg locally, which version of Cython did you use?**: 0.29.33
* **Can the issue be reproduced under both asyncio and
[uvloop](https://github.com/magicstack/uvloop)?**: not tested, since unlikely
I would expect the `datetime.datetime` object has the same timezone as psql or python determines (`CET`).
Instead, asyncpg sets the timezone to `UTC`.
psql shell, displays UTC+1 = CET properly:
```
=> select now()::timestamptz;
2023-02-19 01:53:28.453411+01
```
python-shell:
```python
>>> loop = asyncio.new_event_loop()
>>> c = loop.run_until_complete(asyncpg.connect(database='lol'))
>>> loop.run_until_complete(c.fetch("select now()::timestamptz"))
[]
# ^ here, i'd expect it to be with tzinfo=datetime.timezone(datetime.timedelta(seconds=3600), 'CET')
# because python does the same thing when having timezoned timestamps:
>>> datetime.datetime.now().astimezone()
datetime.datetime(2023, 2, 19, 1, 57, 12, 260030, tzinfo=datetime.timezone(datetime.timedelta(seconds=3600), 'CET'))
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo il comportamento segnalato di timestamptz in PostgreSQL 15.1 con asyncpg 0.27.0 e Python 3.10.9 su Linux, confrontando l'output di psql con il datetime restituito. Traccia il percorso di decodifica del timestamp e individua i test esistenti che coprono i valori timestamptz. Il lavoro è completato quando il datetime restituito conserva il comportamento previsto del fuso orario locale del database e la regressione è coperta da un test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- postgresql, python
- Ambito
- databases
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100