Generic connection types and SaveChangesDsl #3158
Justice4Joffrey
started this conversation in
Ideas
Replies: 1 comment
-
This could likely be solved at application level by using the following function signature: fn do_thing<C>(conn: C)
where C: Connection<Backend = SomeBackend>,
YourType: SaveChangesDsl<C>,
{
// database things
} Possibly it's even possible to write some sort of "super" trait that just implies
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to write my db operations like so:
The result is that this is available the caller uses a
PooledConnection
or aConnection
.This works fine for the most part, but
SaveChangesDsl
is awkward - it's implemented on concrete connections (e.g.PgConnection
,PooledConnection<M>
whereM::Connection
implsUpdateAndFetchResults
). Therefore, there isn't a single trait impl I can use which will allow this. Also, requiringUpdateAndFetchResults<Changes, Output>
at the call site will leak all specific implementations which will awkwardly have to be propagated up the call stack.It's obviously fairly simple for me to not use
SaveChangesDsl
with this workflow, but would imagine this could simplify a lot of diesel use where both pooled and single connections are sharing the same functionality.Interested to hear whether this could be supported and what an implementation might look like.
Beta Was this translation helpful? Give feedback.
All reactions