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

Add Serialize/Deserialize for std::ops::Bound<DateTime> and friends #299

Closed
manifest opened this issue Jan 24, 2019 · 9 comments
Closed

Comments

@manifest
Copy link
Contributor

Would be useful for serializing PostgreSQL time range data types: tsrange, tstzrange, daterange that are already supported by Diesel.

@manifest manifest changed the title Add Serialize/Deserialize for Bound<DateTime> and (Bound<DateTime>, Bound<DateTime>) Add Serialize/Deserialize for (Bound<DateTime>, Bound<DateTime>) Jan 24, 2019
@quodlibetor
Copy link
Contributor

Where does the Bound type come from?

Either way you ought to be at least partially unblocked by using serde's support for remote crates

@manifest
Copy link
Contributor Author

manifest commented Jan 24, 2019

Where does the Bound type come from?

Diesel implements PostgreSQL range data types as (Bound<T>, Bound<T>) where T: FromSql<ST, Pg> and it looks as a good solution for ranges in general.

Either way you ought to be at least partially unblocked by using serde's support for remote crates

Sure, but it would be great to have such feature right out of the box.

@quodlibetor
Copy link
Contributor

I agree it would be nice. I think that this feature belongs in diesel, though, since diesel depends on chrono not the other way around.

@quodlibetor quodlibetor changed the title Add Serialize/Deserialize for (Bound<DateTime>, Bound<DateTime>) Add Serialize/Deserialize for Diesel's (Bound<DateTime>, Bound<DateTime>) Jan 24, 2019
@manifest
Copy link
Contributor Author

manifest commented Jan 25, 2019

I think about that as a support for serialization and deserialization for time ranges in general. Because Bound is a native data type for Rust, it seems as the best candidate for time ranges. I mean the type itself may be useful without Diesel.

@quodlibetor
Copy link
Contributor

Ah, yes, when you responded that Bound was implemented by diesel I thought you meant that it was a diesel-defined type, but I believe you are referring to std::ops::Bound?

Implementation-wise, that seems straightforward. Currently the serde feature is guaranteed to work with rust 1.15, and Bound was only added in 1.17, so this should be behind a serde-bound feature flag until chrono 0.5.

A PR that implements that would be very welcome!

@quodlibetor quodlibetor changed the title Add Serialize/Deserialize for Diesel's (Bound<DateTime>, Bound<DateTime>) Add Serialize/Deserialize for std::ops::Bound<DateTime> and friends Jan 25, 2019
@manifest
Copy link
Contributor Author

Yes, I was referring to std::ops::Bound.

@0nkery
Copy link

0nkery commented Jan 29, 2019

I think, there is no way (and no need, actually) to implement Serialize/Deserialize for Bound<DateTime> inside this crate.

Instead, this PR will allow to ser/de Bound<DateTime> when it will be merged - serde-rs/serde#1466.

We can close this issue, I guess?

@manifest
Copy link
Contributor Author

We still need a few serde helpers (ts_seconds, etc) I believe.

@quodlibetor
Copy link
Contributor

the serde helpers are only needed for the module helpers, which I don't think will be necessary for interacting with diesel's serde support.

I'm going to close this for now in favor of 0nkery's serde patches, but if those don't help enough then we can re-open or open a new, more specific, issue.

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

No branches or pull requests

3 participants