TestCase + select_for_update()
|Reported by:||andreas_pelme||Owned by:||nobody|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Since 1.6.3 and the select_for_update() changes, TransactionManagementError is raised when run in autocommit mode.
However, in TestCase subclasses select_for_update() with missing transaction.atomic() blocks are not detected, since the test case itself runs in an atomic block.
This means that select_for_update() errors will be silent in most test suites, and then show up in production.
I think a lot of pain could be saved if it was possible to detect these cases and raise an exception in the tests to point out problems. I am not sure how (if) that could be accomplished, but if it was possible, I think it would be a big win. I would be happy to work on a patch if you think this would be a feasible idea.
Change History (7)
comment:1 Changed 18 months ago by aaugustin
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 18 months ago by timo
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Uncategorized to Cleanup/optimization
comment:3 Changed 15 months ago by mardini
- Component changed from Database layer (models, ORM) to Documentation
- Has patch set
- Version changed from 1.6 to master
comment:5 Changed 15 months ago by Tim Graham <timograham@…>
- Resolution set to fixed
- Status changed from new to closed