Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot commit transaction more than once #61

Closed
kwaazaar opened this issue Sep 22, 2016 · 5 comments
Closed

Cannot commit transaction more than once #61

kwaazaar opened this issue Sep 22, 2016 · 5 comments

Comments

@kwaazaar
Copy link

@kwaazaar kwaazaar commented Sep 22, 2016

Wrong description, but when committing a transaction, the SqlTransaction's Connection-property turns null. I depend on this behavior (perhaps I shouldn't), but for this library, the connection is not nulled on the transaction. Maybe this is something you would want to change to mimic the SqlTransactions' behaviour more.

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Sep 23, 2016

I'll need to check if MySql.Data implements this behaviour; if it doesn't, this would be a potentially-breaking change for users switching from that MySQL provider to this library.

Additionally, clearing the connection when the transaction is committed isn't an obviously documented behaviour of DbTransaction.Connection or IDbTransaction.Connection, so it's not clear that this is a required or standard part of ADO.NET.

I'll investigate, but my initial inclination is (for better or worse) to clone MySqlTransaction's behaviour here rather than SqlTransaction. The right solution might be to track (in your calling code) whether you've called Commit (and/or Rollback?) or not.

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Sep 23, 2016

Interestingly, this behaviour is documented for SqlTransaction.Connection:

Gets the SqlConnection object associated with the transaction, or null if the transaction is no longer valid.

But it's not documented as such on the base class or the interface.

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Sep 23, 2016

Npgsql appears to follow the SqlTransaction model.

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Jan 1, 2018

I checked this with AdoNet.Specification.Tests (https://github.com/mysql-net/AdoNetApiTest) and only Connector/NET doesn't clear DbTransaction.Connection when a transaction is committed (or rolled back).

image

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Jan 2, 2018

Fixed in 0.34.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants