MagicStack / MagicStack/asyncpg
Impossible to select arbitrary column when using SQLAlchemy
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 8.1k
- Fork
- 468
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
- 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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện truy vấn chọn cột của SQLAlchemy với các phiên bản Python, PostgreSQL và package được báo cáo, sau đó kiểm tra SQL được chuyển đến asyncpg thông qua databases. Xác nhận liệu truy vấn được tạo có gây ra lỗi không khớp kiểu dữ liệu hay không; hoàn thành khi việc chọn một tập con các cột được thực thi thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- postgresql, python, sqlalchemy
- Lĩnh vực
- backend, databases
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100