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

Filtering history with ?collection_id=0 returns an empty list #851

Closed
leplatrem opened this issue Oct 5, 2016 · 2 comments
Closed

Filtering history with ?collection_id=0 returns an empty list #851

leplatrem opened this issue Oct 5, 2016 · 2 comments
Assignees

Comments

@leplatrem
Copy link
Contributor

  • Create a collection whose name is 0
  • Filter the history with ?collection_id=0
  • Instead of obtaining the history entry, the obtained list is empty
@gabisurita
Copy link
Member

gabisurita commented Oct 6, 2016

This may not only be related to history entries.

If we create the collections with ids 0, 1 and string, the behavior is different when selecting via the id parameter.

$ echo '{"data": {"description": "Collection Zero"}}' | http PUT https://kinto.dev.mozaws.net/v1/buckets/default/collections/0 -v --auth 'hey:you'

$ echo '{"data": {"description": "Collection One"}}' | http PUT https://kinto.dev.mozaws.net/v1/buckets/default/collections/1 -v --auth 'hey:you'

$ echo '{"data": {"description": "Collection String"}}' | http PUT https://kinto.dev.mozaws.net/v1/buckets/default/collections/string -v --auth 'hey:you'

$ http GET https://kinto.dev.mozaws.net/v1/buckets/default/collections -v --auth 'hey:you'

{
    "data": [
        {
            "description": "Collection String", 
            "id": "string", 
            "last_modified": 1475731844316
        }, 
        {
            "description": "Collection One", 
            "id": "1", 
            "last_modified": 1475731818775
        }, 
        {
            "description": "Collection Zero", 
            "id": "0", 
            "last_modified": 1475731794491
        }
    ]
}
$ http GET https://kinto.dev.mozaws.net/v1/buckets/default/collections?id=string -v --auth 'hey:you'

{
    "data": [
        {
            "description": "Collection String", 
            "id": "string", 
            "last_modified": 1475731844316
        }
    ]
}
$ http GET https://kinto.dev.mozaws.net/v1/buckets/default/collections?id=0 -v --auth 'hey:you'

{
    "data": []
}
$ http GET https://kinto.dev.mozaws.net/v1/buckets/default/collections?id=1 -v --auth 'hey:you'

{
    "data": []
}

@Natim Natim self-assigned this Oct 6, 2016
@leplatrem
Copy link
Contributor Author

leplatrem commented Oct 6, 2016

Nice catch @gabisurita !

The problem comes indeed that we interpolate the field value as a native python value (which is integer) and then compare it with a string (id).

I remember also that we don't want to compare with string if the store value is an integer.

The fix might not be so easy actually, since we don't always have the schema of the data.

We could maybe filter with something like field IN ("0", 0) but I find it very ugly...

leplatrem added a commit that referenced this issue Oct 10, 2016
Fix filtering with numeric id (fixes #851)
leplatrem added a commit that referenced this issue Oct 25, 2016
Fix filtering with numeric id (fixes #851)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants