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

Compatibility with chrono via feature flag #1599

Open
t3hmrman opened this issue Mar 2, 2024 · 2 comments
Open

Compatibility with chrono via feature flag #1599

t3hmrman opened this issue Mar 2, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@t3hmrman
Copy link

t3hmrman commented Mar 2, 2024

Thanks for this awesome project, huge fan and user of pgrx!

Often when working with date-times and other temporal Postgres types, I often end up converting to chrono native types -- it would be nice if pgrx had a chrono feature flag that exposed some simple From/TryFrom/etc implementations.

I'd be willing to work on this if it was something ya'll would be willing to consider

@workingjubilee
Copy link
Member

That seems reasonable, the only caveat I will note is that our current implementations for these datetime types don't adequately bound themselves in some cases, but I intend to fix that Somewhat Soon.

Postgres offers pretty generous limits but they do exist, and offers different precisions. This makes converting to/from Chrono types somewhat error prone. So I "most want" these in the case where there is

  • no precision loss when converted into the Postgres type
  • no out-of-bounds values when converted into Postgres type

@workingjubilee workingjubilee added the enhancement New feature or request label Mar 2, 2024
@t3hmrman
Copy link
Author

t3hmrman commented Mar 10, 2024

Hey @workingjubilee I've got a draft PR of one conversion (pgrx::datum::Date -> chrono::NaiveDate) and would appreciate some early feedback if you can find some spare time!

#1603

These tests are certainly a good candidate for proptests, the test that's in there right now is just a simple static test -- I can certain make sure that these are proptested while I'm here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants