-
-
Notifications
You must be signed in to change notification settings - Fork 462
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
Provide a implementation of diesel::connection::Connection
as part of the connection type of this crate
#890
Comments
@sfackler Is there any additional information I could provide to help you making a decision on this? Or is it just that someone needs to implement it? |
It might make more sense to do this on the diesel side of things? |
Not necessarily. Doing this in diesel would require wrapping the connection type into a new type wrapper to store additional state, so users would loose access to the underlying connection type. Additionally this likely would duplicate prepared statement and type oid caching as the connection impl? Another potential problem is around data (de)serialization. While that is possible to do as part of diesel (there is a older PR already there), it might be easier to implement this as part of postgres, because here such an impl would have easier access to the underlying byte buffers. That written: If you are complete opposed to this idea this is totally acceptable for me. I just like to go through all possible solutions and see which one might be the best solution. |
If extra state is required, it'd probably need a wrapper type either way since I don't think I'd want to add thing to The client doesn't perform any statement caching internally. Third party code can have direct access to the underlying buffers by implementing |
So let me summarize different potential options with some advantages and disadvantages from my point of view here: Include a rust-postgres connection implementation in diesel itselfThis would need to provide an wrapping struct around Pros:
Cons:
Include a diesel connection implementation in rust-postgresThis needs either a wrapper struct around Pros:
Cons:
Publish such a connection implantation as separate crateThe implementation idea described for diesel should also work in any other third party crate, so theoretically we could publish a Pros:
Cons:
|
I'm not sure what kind of OID tracking you need, but you can get them directly out of the I think I would lean towards this being a separate crate. |
OID tracking is required by diesel for constructing prepared statements containing custom types. That would essentially require to construct a EDIT: I'm closing this issue now, as I got my answer and this seems to be out of scope here. |
Would really like to see this! |
I'd really love to see this too, it'd be great to be able to use Diesel without relying on libpq. |
This is more a feature request/suggestion than a bug report.
As part of the diesel 2.0 release we reworked large parts of diesels internals, such that it should now be possible to provide a custom
Connection
implementation for the existing diesel postgres backend outside of the main crate. Your crate would be a good candidate for this as it already provides a pure rust postgres connection implementation. I expect that there would be a certain demand in having a pure rust connection implementation supported by diesel as well.A diesel connection implementation would enable the usage of any supported diesel feature with a connection type from your crate. This includes all of the existing query DSL, all methods to load and map results to rust struct and even the existing migration infrastructure.
This would require implementing
diesel::connection::Connection
either directly for your connection type or indirectly via a wrapper type. Providing this implementation as part of your crate would enable a better integration with optimizations like prepared statement caching.If you are interested in such feature I'm happy to provide guidance on writing the corresponding code. I might even be able to help writing parts of the implementation.
The text was updated successfully, but these errors were encountered: