Skip to content

Fix missing query-actions buttons for queries with date/datetime params. #1019

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

Merged
merged 2 commits into from
Jan 29, 2018

Conversation

jieter
Copy link
Contributor

@jieter jieter commented Dec 22, 2017

The param strings_only=True caused params with type time, date and
datetime to not be converted to string by NormalCursorWrapper._decode(),
and in turn causes the json dumping to fail.

This change keeps strings_only=True for every type but datetime, date and
time, enabling conversion to string in those cases.

Fixes #882

@jieter
Copy link
Contributor Author

jieter commented Dec 22, 2017

Apparently I'm a bit too optimistic on the support of those date/time lookups in django, let me fix that.

@codecov
Copy link

codecov bot commented Dec 22, 2017

Codecov Report

Merging #1019 into master will decrease coverage by 0.31%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1019      +/-   ##
==========================================
- Coverage   84.65%   84.33%   -0.32%     
==========================================
  Files          25       24       -1     
  Lines        1323     1296      -27     
  Branches      182      176       -6     
==========================================
- Hits         1120     1093      -27     
  Misses        155      155              
  Partials       48       48
Impacted Files Coverage Δ
debug_toolbar/panels/sql/tracking.py 83.83% <100%> (+2.39%) ⬆️
debug_toolbar/panels/templates/views.py 61.9% <0%> (-7.33%) ⬇️
debug_toolbar/panels/templates/panel.py 85.93% <0%> (-2.35%) ⬇️
debug_toolbar/panels/cache.py 80.35% <0%> (-1.1%) ⬇️
debug_toolbar/panels/request.py 100% <0%> (ø) ⬆️
debug_toolbar/compat.py

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b7672d9...e75a579. Read the comment docs.

@jieter
Copy link
Contributor Author

jieter commented Dec 22, 2017

I changed the test so it passed on all test environments. Unfortunately, this means I cannot test time and date, as no fields on user are of that time an the __time and __date lookups are not widely supported yet.

The param `strings_only=True` caused params with type `time`, `date` and
`datetime` to not be converted to string by `NormalCursorWrapper._decode()`,
and in turn causes the json dumping to fail.

This change keeps `strings_only=True` for every type but datetime, date and
time, enabling conversion to string in those cases.

Fixes django-commons#882
@@ -114,7 +117,7 @@ def _record(self, method, sql, params):
_params = ''
try:
_params = json.dumps([self._decode(p) for p in params])
except Exception:
except TypeError as e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit surprised that this pull request passes the build, since this is an unused variable right here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange indeed. Just pushed a commit removing the variable.

@matthiask matthiask merged commit e75a579 into django-commons:master Jan 29, 2018
@jieter jieter deleted the date-params branch January 29, 2018 14:50
@jieter
Copy link
Contributor Author

jieter commented Jun 1, 2018

@matthiask ran into this bug again today, it would be nice to have this into a released version. Is there a plan to do a new release?

@matthiask
Copy link
Member

Thanks for the reminder. It's on a long list of things I want to do. I'll hopefully get around to it in the next few days.

@jieter
Copy link
Contributor Author

jieter commented Aug 31, 2018

@matthiask I'm a bit hesitant to bug you again, but can I do anything to help to get this released? (ran into another query with date-params I wanted to debug...

@matthiask
Copy link
Member

matthiask commented Sep 14, 2018

Posting here because it took such a long time to do this: 1.10.1 has been released this week.

@jieter
Copy link
Contributor Author

jieter commented Sep 14, 2018

Yes, I noticed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants