Improve compatibility and usage of CursorDebugWrapper.
Review Request #8685 — Created Jan. 31, 2017 and submitted
This improves
CursorDebugWrapper
to be compatible with modern versions
of Django, and to implement missing functionality.Our
CursorDebugWrapper
was re-implementing logic from Django's, instead
of just using the base logic, which didn't make sense and wasn't
future-proof. We now heavily rely on the base functionality.We register
CursorDebugWrapper
in a better way. The old way of
overriding the version on the module wasn't safe, and caused infinite
loop issues on newer versions of Django. We now instead override the
method onBaseDatabaseWrapper
that creates and returns an instance of
theCursorDebugWrapper
, which is safer.Last but not least, we weren't adding stack traces for
executemany()
calls. While Django itself doesn't make use of this method, applications
might. We now store the stack trace for these calls as well.Unit tests were added for both methods.
Unit tests pass on Django 1.6, 1.7, 1.8, 1.9, and 1.10.
- Change Summary:
-
Fixed unused imports.
- Commit:
-
eec7f403ca95b162c621e4ba7f54fc4606a2cfc6ca0ed92db293d9a5c80d1a3be7eb5da8da3cdf5c
-
Tool: PEP8 Style Checker Processed Files: djblets/log/tests/test_cursor_debug_wrapper.py djblets/log/middleware.py Ignored Files: djblets/log/tests/__init__.py Tool: Pyflakes Processed Files: djblets/log/tests/test_cursor_debug_wrapper.py djblets/log/middleware.py Ignored Files: djblets/log/tests/__init__.py