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

Fixes bug 1207085 - Do not consider 0 as a falsy value in API. #3002

Merged

Conversation

adngdb
Copy link
Contributor

@adngdb adngdb commented Sep 22, 2015

@peterbe r?

I'm also upgrading elasticsearch-dsl to fix a bug: when you were querying for 0 results, it would instead return Elasticsearch's default number of results, which is 10. That's fixed with the latest version.

if param['required'] and not value and value != 0:
raise RequiredParameterError(name)

if not value and value != 0:
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

So, if this continue happens, does that not mean the value isn't made available? Can't you just do:

if not value and value != 0:
    if param['required']:
        raise RequiredParameterError(name)
    continue

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't put my finger on it but it feels strange that you're doing the ... != 0 check twice.

@peterbe
Copy link
Contributor

peterbe commented Sep 22, 2015

@AdrianGaudebert Note that the tests don't pass.

@adngdb
Copy link
Contributor Author

adngdb commented Sep 23, 2015

Well, TIL:

> False != 0
False
> False is not 0
True

@adngdb
Copy link
Contributor Author

adngdb commented Sep 23, 2015

@peterbe comments addressed!

@peterbe
Copy link
Contributor

peterbe commented Sep 23, 2015

Awesome! r+

@adngdb adngdb force-pushed the 1207085-super-search-zero-false branch from 8cafc40 to 707c997 Compare September 23, 2015 16:28
@adngdb adngdb merged commit 707c997 into mozilla-services:master Sep 23, 2015
@adngdb adngdb deleted the 1207085-super-search-zero-false branch September 23, 2015 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants