Skip to content
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

Supports negative years for date and timestamp types #391

Closed
wants to merge 1 commit into from

Conversation

jlavelle
Copy link
Member

@jlavelle jlavelle commented Nov 9, 2024

Previously we were ISO8601 encoding/decoding dates and timestamps with negative years, however PostgreSQL uses a "BC" suffix to indicate negative years. I added support for this syntax to the Day, UTCTime, and LocalTime SqlTypes, and expanded the range of years generated in testing to ensure we're handling the negative years correctly.

Closes #380.

Copy link
Contributor

@telser telser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Just a question for the tests.

orville-postgresql/test/Test/PgGen.hs Outdated Show resolved Hide resolved
Previously we were ISO8601 encoding/decoding dates and timestamps with
negative years, however PostgreSQL uses a "BC" suffix to indicate
negative years. I added support for this syntax to the `Day`, `UTCTime`,
and `LocalTime` `SqlType`s, and expanded the range of years generated in
testing to ensure we're handling the negative years correctly.
@jlavelle jlavelle force-pushed the nebula/support-negative-years branch from aae6554 to c812edf Compare November 10, 2024 00:28
@jlavelle
Copy link
Member Author

jlavelle commented Nov 10, 2024

There's an off-by-one bug because PostgreSQL considers -1 to be 1 B.C.E, whereas time follows ISO8601 where 0 is 1 B.C.E. :) I just missed this when implementing. With ISO8601, the year -40 is 41 B.C.E., so we need to encode it as 0041 BC.

@jlavelle
Copy link
Member Author

Closing for now because I have to make rather significant changes.

@jlavelle jlavelle closed this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Invalid syntax' generated with negative years
2 participants