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

Bug: DbRepository's Truncate operations do not handle transactions #1041

Closed
zetomatoz opened this issue Mar 29, 2022 · 1 comment
Closed
Assignees
Labels
bug Something isn't working todo Things to be done in the future

Comments

@zetomatoz
Copy link

The DbRepository class' Truncate methods do not handle the transaction argument correctly. A connection instance gets created even if transaction is not null, which leads to runtime issues.

public int Truncate<TEntity>(IDbTransaction transaction = null) where TEntity : class
{
    // Create a connection
    var connection = CreateConnection();
    
    // Code removed for brevity
}

We should get the following implementation as it is done with the other DbRepository's operations:

public int Truncate<TEntity>(IDbTransaction transaction = null) where TEntity : class
{
    // Create a connection
    var connection = (transaction?.Connection ?? CreateConnection())
    
    // Code removed for brevity
}
@zetomatoz zetomatoz changed the title [Bug] DbRepository's Truncate operations do not handle transactions Bug: DbRepository's Truncate operations do not handle transactions Mar 29, 2022
@mikependon mikependon self-assigned this Mar 30, 2022
@mikependon mikependon added bug Something isn't working todo Things to be done in the future labels Mar 30, 2022
@mikependon
Copy link
Owner

Thanks for reporting. It is a simple fix though. We are glad if you can also make a PR of this, otherwise we will do the fix and it will be a part of the release.

SergerGood added a commit that referenced this issue Apr 6, 2022
mikependon added a commit that referenced this issue Apr 6, 2022
Bug #1041: DbRepository's Truncate operations do not handle transactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working todo Things to be done in the future
Projects
None yet
Development

No branches or pull requests

2 participants