-
-
Notifications
You must be signed in to change notification settings - Fork 251
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
Opaque Date type with +/- infinity support #622
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good! I mostly have a few remarks about the question of the unsafe
code / PGX <-> Postgres interop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good!
My only remarks are, now that the dust has settled on everything else and I can see the conversions we are going to provide: When the conversion is for a Rust type and not a C typedef, we can use the conversion traits that Rust normally provides via the prelude to define the conversion.
There are reasons to do otherwise, like type inference on the conversion and syntactic niceties, but I don't think they apply here because it's a fairly direct conversion. Rather, the pressure is on to provide it ourselves, since only two other crates can implement these conversions (and in practice only one).
I think by returning the deprecated Hopefully they will forgive us when we say it's ultimately for performance reasons. |
I think it's reasonable. :) |
I switched the Date type with one that's an alias for the
i32
datum.try_get_date(&self)
will get you atime:Date
if it's within thetime
crate's bounds, or anErr(pg_epoch_days: i32)
if out of range.-infinity
andinfinity
are handled on their own.I moved the serialization
#[test]
to#[pg_test]
so that serialization can leverage PG's built in serialization. This is especially important for values outside oftime:Date
bounds which we couldn't format/serialize otherwise.