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

Remove checking if DB engine supports transaction during import #559

Conversation

mkurek
Copy link

@mkurek mkurek commented Dec 30, 2016

PR #480 introduced proper handling of transactions during import, but with additional check if DB engine does support transactions.

When transaction is already in atomic block (for example by using ATOMIC_REQUESTS in Django DB conf) and import_data performs check if DB support transaction, in some cases (like MySQL), this check tries to call set_autocommit, which is forbidden in atomic block. This fix it by not using supports_transaction at all (it's not used in whole Django at all either, besides tests) - previously user receives ImproperlyConfigured exception - now transaction.atomic will go through silently (for example in MyISAM case) or raise another exception to user, but it'll work for all engines that support DB transactions when transaction block is already entered.

PR django-import-export#480 introduced proper handling of transactions during import, but with additional check if DB engine does support transactions.

When transaction is already in atomic block (for example by using `ATOMIC_REQUESTS` in Django DB conf) and `import_data` performs check if DB support transaction, in some cases (like MySQL), this check tries to call `set_autocommit`, which is forbidden in atomic block. This fix it not to use `supports_transaction` at all (it's not used in whole Django at all either, besides tests) - previously user receives `ImproperlyConfigured` exception - now `transaction.atomic` will go through silently (for example in MyISAM case) or raise another exception to user, but it'll work for all engines that support DB transactions when transaction block is already entered.
@ar4s
Copy link

ar4s commented Aug 4, 2017

@bmihelac ping

@bmihelac
Copy link
Member

Transaction handling was refactored with 9a32c6e

Can you check if issue still persist and if possible add a failing test case if it is not?

thnx

@stale
Copy link

stale bot commented Feb 11, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Stale bot label Feb 11, 2019
@stale stale bot closed this Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants