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

Handle filters with integer values #2004

Closed
wants to merge 3 commits into from

Conversation

zallek
Copy link

@zallek zallek commented Jan 19, 2017

Fixing #1640

query_filters was surrounding filter value with quotes if the value contains ,. Leading that if the value was an integer it fails on if "," in x.
Casting value to string fixes both UI problems listed in the issue.

PS: I tried to not cast the value from integer to string, but then DB request wasn't working. So this fix seems to be more appropriate.
PS: This part doesn't seem to be tested, am I wrong?

@@ -260,9 +260,15 @@ def query_filters(self, is_having_filter=False):
if not (col and vals):
continue
elif col in self.datasource.filterable_column_names:
# Quote values with comma to avoid conflict
vals = ["'{}'".format(x) if "," in x else x for x in vals]
Copy link
Contributor

Choose a reason for hiding this comment

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

This should work fine too:
vals = ["'{}'".format(x) if "," in x else "{}".format(x) for x in vals]

Copy link
Author

Choose a reason for hiding this comment

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

No, it won't because it will still try to test if "," is in x which fails when x is an integer.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah! got it. What about this?

from six import text_type
vals = map(text_type, vals)
vals = [u"'{}'".format(x) if "," in x else x for x in vals]

@bkyryliuk
Copy link
Member

should be fixed on master already: #1978

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.

3 participants