pgrx icon indicating copy to clipboard operation
pgrx copied to clipboard

feat(pgrx): add chrono feature for easy conversions

Open t3hmrman opened this issue 1 year ago • 8 comments

This commit adds a chrono feature flag to pgrx, which enables conversions between pgrx native date/time (with or without timezone) and chrono types like NaiveDateTime.

t3hmrman avatar Mar 10 '24 13:03 t3hmrman

I think you're probably on the right track here. I suppose we'd want to also have conversions from the chrono types into the Postgres types.

I don't know how far @workingjubilee might want to take this in terms of also supporting IntoDatum/FromDatum for the chrono types (not clear to which SQL type they'd map to), so that's an open question...

eeeebbbbrrrr avatar Mar 11 '24 15:03 eeeebbbbrrrr

Yeah, this seems like the right direction.

I don't think we want to support IntoDatum/FromDatum for these types. I would rather move towards making it easier to distinguish when something is a "zero-overhead" or "direct" conversion that is natively supported by Postgres, and when something requires additional logic like these types always will.

workingjubilee avatar Mar 11 '24 16:03 workingjubilee

Thanks for the check @workingjubilee @eeeebbbbrrrr and for the heads up -- just to confirm I do plan to add the conversions both ways.

Will finish up the rest of it in this pattern and turn this to ready for review hopefully soon!

t3hmrman avatar Mar 11 '24 17:03 t3hmrman

Hey @workingjubilee @eeeebbbbrrrr just finished the first version of this, would love a review whenever you can find some time!

I've tried to be pretty explicit about where the microseconds-only limitation of pg comes into play. I'm also equally happy to put this functionality in some sort of external crate if you'd prefer to not upstream this functionality as well!

t3hmrman avatar Apr 11 '24 07:04 t3hmrman

Hi !

Is there's a way for me to help moving this PR forward ? It would be very useful in my own extension...

daamien avatar Jul 01 '24 08:07 daamien

Rebased just to make sure that's not blocking progress here :)

t3hmrman avatar Jul 01 '24 09:07 t3hmrman

Sorry, all my focus was being consumed by https://github.com/pgcentralfoundation/pgrx/pull/1731 since that was one of our last release blockers so reviewing anything that wasn't incredibly trivial was backburnered.

workingjubilee avatar Jul 01 '24 19:07 workingjubilee

@workingjubilee absolutely no problem -- thanks for taking a look (P.S. I saw the other thing you were working on :+1: :+1: :+1:).

Will add the additional tests!

t3hmrman avatar Jul 02 '24 03:07 t3hmrman

Hi - any particular reason for closing down this PR?

LucaCappelletti94 avatar Apr 12 '25 11:04 LucaCappelletti94