MagicStack / MagicStack/asyncpg
Impossible to select arbitrary column when using SQLAlchemy
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: asyncpg==0.21.0
- PostgreSQL version: 13
- Python version: 3.6
- Platform: Alpine Linux (3.8)
- Do you use pgbouncer?: no
- Did you install asyncpg with pip?: yes
- If you built asyncpg locally, which version of Cython did you use?: N/A
- Can the issue be reproduced under both asyncio and
uvloop?: I don't know, I'm using uvloop right now
I'm trying to use asyncpg with SQLAlchemy on a project of mine. However, the following constructs to select a subset of columns in the underlying table doesn't work:
query = mytable.select(mytable.c.date)
results = await database.fetch_all(query)
This raises the following error:
File "./main.py", line 140, in post_telemetry
tel_results = await vmo.database.fetch_all(tel_query)
File "/usr/local/lib/python3.6/site-packages/databases/core.py", line 140, in fetch_all
return await connection.fetch_all(query, values)
File "/usr/local/lib/python3.6/site-packages/databases/core.py", line 239, in fetch_all
return await self._connection.fetch_all(built_query)
File "/usr/local/lib/python3.6/site-packages/databases/backends/postgres.py", line 160, in fetch_all
rows = await self._connection.fetch(query, *args)
File "/usr/local/lib/python3.6/site-packages/asyncpg/connection.py", line 443, in fetch
return await self._execute(query, args, 0, timeout)
File "/usr/local/lib/python3.6/site-packages/asyncpg/connection.py", line 1446, in _execute
query, args, limit, timeout, return_status=return_status)
File "/usr/local/lib/python3.6/site-packages/asyncpg/connection.py", line 1454, in __execute
return await self._do_execute(query, executor, timeout)
File "/usr/local/lib/python3.6/site-packages/asyncpg/connection.py", line 1466, in _do_execute
stmt = await self._get_statement(query, None)
File "/usr/local/lib/python3.6/site-packages/asyncpg/connection.py", line 351, in _get_statement
statement = await self._protocol.prepare(stmt_name, query, timeout)
File "asyncpg/protocol/protocol.pyx", line 163, in prepare
asyncpg.exceptions.DatatypeMismatchError: argument of AND must be type boolean, not type timestamp with time zone
As far as I can't tell, asyncpg doesn't seem to support this feature that is present in SQLAlchemy since version 1.4, but I may be wrong.
Let me know if you need additional information.
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 la query di selezione delle colonne di SQLAlchemy con le versioni segnalate di Python, PostgreSQL e dei pacchetti, quindi esamina l’SQL passato ad asyncpg tramite databases. Conferma se la query generata causa l’errore di incompatibilità dei tipi; il lavoro è completato quando la selezione di un sottoinsieme di colonne viene eseguita correttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- postgresql, python, sqlalchemy
- Ambito
- backend, databases
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100