aaberg / sql2o

sql2o is a small library, which makes it easy to convert the result of your sql-statements into objects. No resultset hacking required. Kind of like an orm, but without the sql-generation capabilities. Supports named parameters.
http://sql2o.org
MIT License
1.15k stars 229 forks source link

reset autocommit state when closing the connection #278

Closed zapodot closed 7 years ago

zapodot commented 7 years ago

Our production system is set up with a connection pool that sets the AutoCommit property to true. For some reason had one developer used explicit transactions using Sql2o.beginTransaction which sets AutoCommit to false.

Unfortunately the AutoCommit flag is not reset on "commit" or close which caused problems with the next database operation that got the same recycled connection from the pool with the AutoCommit property still set to "false".

Personally I prefer to always setting autocommit to false and use explicit transactions where needed, but as this is not always the case Sql2o should reset the behaviour before "closing" the connection (i.e returning it to the pool for reeuse)