-
Notifications
You must be signed in to change notification settings - Fork 420
Conversion problem between interval and timedelta #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Just for fun I tried to investigate a bit: effectively the OOC, where did you find the details underlying the |
I found the details in the PG sources (specifically, in I wonder if it'd make any sense in implementing a more PG-like interval Python data type, something like monthdelta but supporting also day fractions... |
This is a POC, targeting issue MagicStack#150: PostgreSQL interval data type and Python timedelta have a similar goal, but are subtly different because PG date arithmetic is much more versatile. So, instead of trying to coerce an interval to a timedelta, the new class aims to carry the same bits of information, and may implement a similar semantic, if needed.
This a quick experiment, please let me know if you think it could be acceptable. If so, I could implement remaining logic to allow a (minimal) interoperability with |
Please give a look at my interval branch, this commit in particular: it implements most of the mentioned interoperability. |
I'm looking forward a review of PR #150 🙏 |
I'm on vacation until next week. Will review once I'm back. Thanks! |
Thank you, have a good time! |
asyncpg will now treat 12-month interval increments as 365-day spans, instead of 12*30 day spans. This matches psycopg2 interval decoding logic. Fixes: #150.
I'm using asyncpg 0.11.0 and I hit a problem with a table containing an
INTERVAL
column.Consider the following script:
It creates a sample table and inserts one record, with a
delay
value of five years, and executing it I get:Commenting out the
CLEANUP_SQL
execution, withpsql
I get:and with pgcli, that uses psycopg2, I get:
Why am I getting back
1800
days when using asyncpg?The text was updated successfully, but these errors were encountered: