-
Notifications
You must be signed in to change notification settings - Fork 38
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
add support for interval #10
Conversation
This looks great! Could you please also add:
|
@isoos Do I create a new version for the changelog? |
yes, please do! e.g. |
@isoos I don't know how to run the tests locally, can you check if my tests are correct? |
I've run the CI tests and this is the failure there: You can create a local docker image similar to this specification to run the tests: |
@isoos I can make it work by increasing the size of the ByteData to 16 instead of 8 when encoding (to match https://github.com/postgres/postgres/blob/master/src/include/catalog/pg_type.dat). But when I write I only set the first 8 bytes ( |
Looks like the interval can store -178000000 years - 178000000 years in postgres in 16 bytes: Let's increase the buffer size to 16, that's one step closer to the correct solution. However, I think we should also handle the second 8 bytes (or throw exception if it is non-null (*) in parsing the value, and also at encoding, if it is negative interval or larger than 8 bytes). (*) I mean not all-zero. |
@isoos What do you think of the implementation now? It do can handle negative values, I don't know what would go in the second part. |
I've found a relevant discussion in the a Go postgresql driver: lib/pq#78 I think I'll try to read a few other implementators code, but if nothing comes up in the next few hours, I'll merge this as-is, and publish it soon after. Maybe an additional test case with very large negative duration would be more reassuring, but this looks good to me. |
perfect test, let's publish this! :) |
2.4.1 is published, thanks for the contribution! |
Very good lib!
I added support for interval type to make it better, I hope it helps others.
Interval is represented as Duration in dart.