[X] Did you check to see if this issue already exists?
[X] Is this only a feature request? Do not put multiple feature requests in one issue.
[X] Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.
[X] Do you agree to follow the rules in our Code of Conduct?
Is your proposal related to a problem?
When using diesel transactions, you need to use an individual postgres connection, rather than passing in an entire DB pool. This is a problem because some API actions, like comment creation, have many operations, and should be done in a transaction.
Currently, nearly all our functions in db_schema use the pool, rather than individual connections. So for the above example, we'd have to create nearly identical functions just for the PgConn versions.
Describe the solution you'd like.
Create a PoolOrConnection enum, and alter all the functions in db_schema to use it, instead of the pool.
Add a helper function to the enum, that if given a pool, extracts the connection, but if given a connection, just uses it.
Requirements
Is your proposal related to a problem?
When using diesel transactions, you need to use an individual postgres connection, rather than passing in an entire DB pool. This is a problem because some API actions, like comment creation, have many operations, and should be done in a transaction.
Currently, nearly all our functions in
db_schema
use the pool, rather than individual connections. So for the above example, we'd have to create nearly identical functions just for thePgConn
versions.Describe the solution you'd like.
Create a
PoolOrConnection
enum, and alter all the functions indb_schema
to use it, instead of the pool.Add a helper function to the enum, that if given a pool, extracts the connection, but if given a connection, just uses it.
Describe alternatives you've considered.
NA
Additional context
4742