MagicStack / MagicStack/asyncpg

BC dates result in error running the query

Đang mở
#404 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

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.18.3=py37h1de35cc_0
  • PostgreSQL version: PostgreSQL 11.1 on x86_64-apple-darwin18.2.0, compiled by Apple LLVM version 10.0.0 (clang-1000.11.45.5), 64-bit
  • **Do you use a PostgreSQL SaaS? No
  • Python version: 3.7
  • Platform: osx
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes
  • If you built asyncpg locally, which version of Cython did you use?: No
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : Tried only asyncio

When a date or datetime column includes dates in the form of 0001-01-01 BC which are valid postgres dates, the driver returns the following:

    result = await executor(stmt, None)
  File "asyncpg/protocol/protocol.pyx", line 196, in bind_execute
  File "asyncpg/protocol/coreproto.pyx", line 65, in asyncpg.protocol.protocol.CoreProtocol._read_server_messages
  File "asyncpg/protocol/coreproto.pyx", line 202, in asyncpg.protocol.protocol.CoreProtocol._process__bind_execute
  File "asyncpg/protocol/coreproto.pyx", line 498, in asyncpg.protocol.protocol.CoreProtocol._parse_data_msgs
  File "asyncpg/protocol/protocol.pyx", line 754, in asyncpg.protocol.protocol.BaseProtocol._decode_row
  File "asyncpg/protocol/prepared_stmt.pyx", line 282, in asyncpg.protocol.protocol.PreparedStatementState._decode_row
  File "asyncpg/protocol/codecs/base.pyx", line 288, in asyncpg.protocol.protocol.Codec.decode
  File "asyncpg/protocol/codecs/base.pyx", line 195, in asyncpg.protocol.protocol.Codec.decode_scalar
  File "asyncpg/pgproto/./codecs/datetime.pyx", line 133, in asyncpg.pgproto.pgproto.date_decode
ValueError: ordinal must be >= 1

ValueError: ordinal must be >= 1

I assume this is some kind of a problem mapping from the BC date to a python date, however this is annoying since valid postgres tables can't be queries. At least in the interim it should be possible to return None if for some reason the date couldn't be parsed but not give up entirely. Is there a quick and dirty way around that?

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu trong asyncpg/pgproto/./codecs/datetime.pyx tại đường dẫn date_decode được hiển thị trong traceback và tái hiện lỗi với một date hoặc datetime của PostgreSQL chứa 0001-01-01 BC. Kiểm tra các bài kiểm thử codec date hiện có và xác định kết quả được hỗ trợ cho các giá trị BC; hoàn thành có nghĩa là việc giải mã một hàng như vậy không còn hủy truy vấn và hành vi này được bao phủ bởi một bài kiểm thử hồi quy.

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

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.