-
-
Notifications
You must be signed in to change notification settings - Fork 339
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
Fix double EXPLAIN when calling explain on queryset #654
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #654 +/- ##
==========================================
- Coverage 86.51% 86.48% -0.03%
==========================================
Files 52 52
Lines 2091 2094 +3
==========================================
+ Hits 1809 1811 +2
- Misses 282 283 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
10e8b7b
to
2485450
Compare
2485450
to
e5f77ca
Compare
for more information, see https://pre-commit.ci
Hey, I just encountered this issue too. I think the changes look good but test coverage is failing. I can help you add some unit tests if you'd like @stereodamage. |
@@ -53,7 +54,11 @@ def _explain_query(connection, q, params): | |||
|
|||
# currently we cannot use explain() method | |||
# for queries other than `select` | |||
prefixed_query = f"{prefix} {q}" | |||
if re.match(f"^{prefix} .*", q): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about using just str.startswith()
instead?
if re.match(f"^{prefix} .*", q): | |
if q.startswith(prefix): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that will work!
@pawelzar that would be nice of you, I appreciate that. Didn't really had much time to look into it again and write new test myself. Anything needed from my side? |
Closes #597, #650.
There's also an idea to wrap call to database into
try..except
and throw something likeProgrammingError
(according to PEP 249) or custom error based on ProgrammingError.