Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.

Add Connection.inTransaction to wrap queries in a transaction block #54

Merged
merged 2 commits into from
Nov 28, 2013

Conversation

dylex
Copy link
Contributor

@dylex dylex commented Oct 30, 2013

There is an unfortunate tension between the desired argument type for this function in plain Connections (=> Future[A]) and in ConnectionPools (T => Future[A]), and so it currently uses a compromise (Connection => Future[A]) which is a bit odd in the former case and too general in the latter. One option is to take this function out of Connection and put it on a new SimpleConnection trait, with a separate function on ConnectionPool.

Also includes some test cases for PostgreSQLConnection.inTransaction.

(This is on top of pull request #53.)

dylex added 2 commits November 1, 2013 23:39
There is an unfortunate tension between the desired argument type for this
function in plain Connections (=> Future[A]) and in ConnectionPools (T =>
Future[A]), and so it currently uses a compromise (Connection => Future[A])
which is a bit odd in the former case and too general in the latter.  One
option is to take this function out of Connection and put it on a new
SimpleConnection trait, with a separate function on ConnectionPool.
@dylex
Copy link
Contributor Author

dylex commented Nov 2, 2013

Any suggestions for better approaches to this? There are many cases where transactions are necessariy, including "upsert" operations and deferred constraints for paired inserts. Most of these usually just require a chain of two or more operations within the transaction without any need for external interaction. Admittedly many of these are better handled by pl/sql functions, but it's nice to have the option.

@mauricio
Copy link
Owner

mauricio commented Nov 3, 2013

Not sure about this yet, still thinking. Gonna try to write some code using it and see how it looks. I also need to build the same functionality using MySQL.

@dylex
Copy link
Contributor Author

dylex commented Nov 3, 2013

I didn't test it (or write a test for it) on mysql but the transaction syntax is the same, so it should just work as is.

@Zwergal
Copy link

Zwergal commented Nov 28, 2013

What is the status on this one? I could really need this functionality to be able to send multiple prepared statements in one transaction.

@mauricio
Copy link
Owner

Gonna be finally merged later today.

mauricio added a commit that referenced this pull request Nov 28, 2013
Add Connection.inTransaction to wrap queries in a transaction block
@mauricio mauricio merged commit 087dc97 into mauricio:master Nov 28, 2013
@dylex dylex deleted the transaction branch November 29, 2013 02:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants