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

Extract common base cursor wrapper class #1479

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions debug_toolbar/panels/sql/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def chunked_cursor(*args, **kwargs):
# prevent double wrapping
# solves https://github.com/jazzband/django-debug-toolbar/issues/1239
cursor = connection._djdt_chunked_cursor(*args, **kwargs)
if not isinstance(cursor, state.Wrapper):
if not isinstance(cursor, BaseCursorWrapper):
return state.Wrapper(cursor, connection, panel)
return cursor

Expand All @@ -74,7 +74,11 @@ def unwrap_cursor(connection):
del connection.chunked_cursor


class ExceptionCursorWrapper:
class BaseCursorWrapper:
pass


class ExceptionCursorWrapper(BaseCursorWrapper):
"""
Wraps a cursor and raises an exception on any operation.
Used in Templates panel.
Expand All @@ -87,7 +91,7 @@ def __getattr__(self, attr):
raise SQLQueryTriggered()


class NormalCursorWrapper:
class NormalCursorWrapper(BaseCursorWrapper):
"""
Wraps a cursor and logs queries.
"""
Expand Down