MagicStack / MagicStack/asyncpg
set_type_codec() doesn't work with copy_records_to_table()
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: 0.23.0
- PostgreSQL version: 9.5.21
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: No and this is on a local PSQL install. - Python version: 3.6.13
- Platform: Ubuntu 16.04.6 LTS
- 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?: Not tried
The following:
await conn.set_type_codec(
"numeric",
encoder=str,
decoder=float,
schema="pg_catalog",
)
Doesn't work when used with copy_records_to_table()
...
File "asyncpg/protocol/protocol.pyx", line 504, in copy_in
File "asyncpg/protocol/protocol.pyx", line 437, in asyncpg.protocol.protocol.BaseProtocol.copy_in
asyncpg.exceptions._base.InternalClientError: no binary format encoder for type numeric (OID 1700)
This is despite solving issue https://github.com/MagicStack/asyncpg/issues/157 which added a binary format codec for numeric types - https://github.com/MagicStack/asyncpg/commit/0f8483517ebde66f3c7cc858fa6ad227c6e3fd64
Can we get the ability to provide a custom decoder without having to also provide an encoder then internally just fall back to the default encoder? I believe it should solve the issue. E.g.
await conn.set_type_codec(
"numeric",
decoder=float,
schema="pg_catalog",
)
or
await conn.set_type_codec(
"numeric",
encoder=None,
decoder=float,
schema="pg_catalog",
)
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
Tái hiện lỗi với set_type_codec() và copy_records_to_table() bằng ví dụ số của issue. Bắt đầu tại asyncpg/protocol/protocol.pyx ở copy_in và BaseProtocol.copy_in, sau đó theo dõi cách codec tùy chỉnh được chọn. Hoàn thành khi có thể sử dụng decoder tùy chỉnh trong khi copy_records_to_table() vẫn lấy được encoder cho numeric.
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
- Lĩnh vực
- 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
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100