with_transaction
with explicitly specified pool names
#24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
pgapp
assumes thatpgapp:squery
andpgapp:equery
in the callback function inwith_transaction
must not containPoolName
if you want those queries to be executed inside the transaction. While this is appropriate in most cases, you may end up with unexpected behaviour when using multiple pool names in your app.In these changes I aim for two goals:
You should be able to specify pool name inside the callback of
with_transaction
. The behaviour should be that if the pool name insquery
orequery
is not specified or equal to the onewith_transaction
was called with, it is considered as queries within the transaction. If the pool name is different, then those queries are working with another pool and are not within the transaction.Example:
The last query (to
pool2
) is outside the transaction, but an error in the query still affects the transaction inpool1
.If nested calls of
with_transaction
with the same pool name take place, they should be ignored as postgres does not support nested transactions anyway.Example:
While
doing_stuff2
is a standalone function making queries in its own transaction, when being called indoing_stuff1
all the queries of both functions become a single transaction.