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

Separate raw value representations of postgresql and mysql backend #2134

Merged
merged 7 commits into from
Sep 25, 2019

Conversation

weiznich
Copy link
Member

@weiznich weiznich commented Aug 3, 2019

This commit separates the raw value representation of the mysql and
postgresql backend from raw &[u8] to specific types that could hold
additional information. To avoid code duplication for commonly used
types an additional trait (BinaryRawValue) is introduced, which is
basically equivalent to AsRef<[u8]> but has the existing
HasRawValue trait as super trait. This is required to workaround
some higher ranked life time issues in rustc.
Additionally some type information are added to the postgresql value
type. Those information may allow to do dynamic type conversations in
future diesel versions.

Basically a improved reimplementation of #1833 on top of #1976. As @sgrif stated there this PR keeps the common impl's in place by adding a BinaryRawValue trait.

That said: I'm not super sure if the newly added public types/functions have meaningful names or if we should choose something different.

cc @pgab

@weiznich weiznich requested a review from a team August 3, 2019 20:44
@weiznich weiznich force-pushed the feature/pg_dynamic_value branch 3 times, most recently from a9ebb3a to 870b503 Compare August 3, 2019 22:17
Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

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

There are some mismatching of type and formatting issues but the implementation looks good to me

@weiznich
Copy link
Member Author

weiznich commented Aug 4, 2019

All remaining build failures are fixed by #2131

@weiznich
Copy link
Member Author

@sgrif Stated that he has some comments on this.

This commit separates the raw value representation of the mysql and
postgresql backend from raw `&[u8]` to specific types that could hold
additional information. To avoid code duplication for commonly used
types an additional trait (`BinaryRawValue`) is introduced, which is
basically equivalent to `AsRef<[u8]>` but has the existing
`HasRawValue` trait as super trait. This is required to workaround
some higher ranked life time issues in rustc.
Additionally some type information are added to the postgresql value
type. Those information may allow to do dynamic type conversations in
future diesel versions.
We don't look at the oid's internally and won't do that any time
soon. So document that behaviour and simplify the code.
@weiznich
Copy link
Member Author

@sgrif I've done the changes we have discussed some weeks ago.

@weiznich
Copy link
Member Author

@JohnTitor Would it possible to get a final review on this (assuming that the CI now succeeds)?
Seans comments are now addressed.

Copy link
Member

@JohnTitor JohnTitor 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

@weiznich weiznich merged commit bd13f24 into diesel-rs:master Sep 25, 2019
sgrif added a commit that referenced this pull request Dec 13, 2019
This was originally included in #2134 with the following comment:

> Additionally some type information are added to the postgresql value
> type. Those information may allow to do dynamic type conversations in
> future diesel versions.

While this may be useful in the future, we should wait until we have a
concrete use case for doing so. At the moment this means we have to
thread a `PgConnection` through various types that otherwise wouldn't
need to carry it, and are stabilizing an API that we aren't even sure
if/how we want to eventually use. Given that every use of `PgConnection`
complicates providing an async implementation, we should be more
conservative about speculative APIs like this.
sgrif added a commit that referenced this pull request Dec 13, 2019
This was originally included in #2134 with the following comment:

> Additionally some type information are added to the postgresql value
> type. Those information may allow to do dynamic type conversations in
> future diesel versions.

While this may be useful in the future, we should wait until we have a
concrete use case for doing so. At the moment this means we have to
thread a `PgConnection` through various types that otherwise wouldn't
need to carry it, and are stabilizing an API that we aren't even sure
if/how we want to eventually use. Given that every use of `PgConnection`
complicates providing an async implementation, we should be more
conservative about speculative APIs like this.
h-michael pushed a commit to h-michael/diesel that referenced this pull request Dec 21, 2019
This was originally included in diesel-rs#2134 with the following comment:

> Additionally some type information are added to the postgresql value
> type. Those information may allow to do dynamic type conversations in
> future diesel versions.

While this may be useful in the future, we should wait until we have a
concrete use case for doing so. At the moment this means we have to
thread a `PgConnection` through various types that otherwise wouldn't
need to carry it, and are stabilizing an API that we aren't even sure
if/how we want to eventually use. Given that every use of `PgConnection`
complicates providing an async implementation, we should be more
conservative about speculative APIs like this.
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.

None yet

2 participants