Merge lp:~fgallina/python-timeline-django/no-query-fix into lp:python-timeline-django

Proposed by Fabián Ezequiel Gallina
Status: Merged
Approved by: James Westby
Approved revision: 22
Merged at revision: 22
Proposed branch: lp:~fgallina/python-timeline-django/no-query-fix
Merge into: lp:python-timeline-django
Diff against target: 37 lines (+9/-1)
2 files modified
timeline_django/filters.py (+1/-1)
timeline_django/tests/test_filters.py (+8/-0)
To merge this branch: bzr merge lp:~fgallina/python-timeline-django/no-query-fix
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+217665@code.launchpad.net

Commit message

Properly handle absence of query in filters

This fixes a TypeError that triggered because django-statsd db patches
caused a max recursion exception that propagated up until the filters,
rendering the query parameter of them as None. Because of this, while
the error was really passed through oops, the final error reported to
the user was related to python-timeline-django.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'timeline_django/filters.py'
2--- timeline_django/filters.py 2012-02-24 20:32:10 +0000
3+++ timeline_django/filters.py 2014-04-29 19:04:42 +0000
4@@ -19,7 +19,7 @@
5
6
7 def _filter_table(query, table, reason):
8- if table in query:
9+ if query is not None and table in query:
10 return query.split(" ", 1)[0] + " <%s query redacted>" % reason
11 return query
12
13
14=== modified file 'timeline_django/tests/test_filters.py'
15--- timeline_django/tests/test_filters.py 2012-02-24 20:32:10 +0000
16+++ timeline_django/tests/test_filters.py 2014-04-29 19:04:42 +0000
17@@ -33,6 +33,10 @@
18 result = filters.filter_session_info(query)
19 self.assertEqual('select <session query redacted>', result)
20
21+ def test_none(self):
22+ result = filters.filter_session_info(None)
23+ self.assertIsNone(result)
24+
25
26 class FilterUserInfoTests(TestCase):
27
28@@ -46,6 +50,10 @@
29 result = filters.filter_user_info(query)
30 self.assertEqual('select <user query redacted>', result)
31
32+ def test_none(self):
33+ result = filters.filter_user_info(None)
34+ self.assertIsNone(result)
35+
36
37 class FilterSessionQueryTests(TestCase):
38

Subscribers

People subscribed via source and target branches