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

Default order of records is not -last_modified #434

Closed
leplatrem opened this issue Feb 10, 2016 · 2 comments
Closed

Default order of records is not -last_modified #434

leplatrem opened this issue Feb 10, 2016 · 2 comments
Assignees
Milestone

Comments

@leplatrem
Copy link
Contributor

While writing kinto-client integration we noticed that creating a list of records using a batch requests didn't preserve the passed order.

@leplatrem
Copy link
Contributor Author

Bug confirmed implicit sort order -last_modified is not enabled

Create batch of records:

echo '{"defaults":{"headers":{"Authorization":"Basic dXNlcjpwYXNz"}},"requests":[{"method":"PUT","headers":{"If-None-Match":"*"},"path":"/v1/buckets/default/collections/blog/records/d914797f-1e55-4dde-ac92-51f4d06ba990","body":{"data":{"id":"d914797f-1e55-4dde-ac92-51f4d06ba990","title":"art1"}}},{"method":"PUT","headers":{"If-None-Match":"*"},"path":"/v1/buckets/default/collections/blog/records/8aadb4d4-c107-4335-a119-81027143cf22","body":{"data":{"id":"8aadb4d4-c107-4335-a119-81027143cf22","title":"art2"}}},{"method":"PUT","headers":{"If-None-Match":"*"},"path":"/v1/buckets/default/collections/blog/records/8712d6c9-8caf-43d3-b70d-7c82d672a1bc","body":{"data":{"id":"8712d6c9-8caf-43d3-b70d-7c82d672a1bc","title":"art3"}}}]}' | http POST http://localhost:8888/v1/batch

Retrieve:

http GET ":8888/v1/buckets/default/collections/blog/records" --auth user:pass
HTTP/1.1 200 OK
Access-Control-Expose-Headers: Content-Length, Expires, Alert, Retry-After, Last-Modified, Total-Records, ETag, Pragma, Cache-Control, Backoff, Next-Page
Cache-Control: no-cache
Content-Length: 283
Content-Type: application/json; charset=UTF-8
Date: Wed, 10 Feb 2016 14:53:32 GMT
Etag: "1455115734732"
Last-Modified: Wed, 10 Feb 2016 14:48:54 GMT
Server: waitress
Total-Records: 3

{
    "data": [
        {
            "id": "8aadb4d4-c107-4335-a119-81027143cf22", 
            "last_modified": 1455115734728, 
            "title": "art2"
        }, 
        {
            "id": "d914797f-1e55-4dde-ac92-51f4d06ba990", 
            "last_modified": 1455115734725, 
            "title": "art1"
        }, 
        {
            "id": "8712d6c9-8caf-43d3-b70d-7c82d672a1bc", 
            "last_modified": 1455115734732, 
            "title": "art3"
        }
    ]
}

With order:

http GET ":8888/v1/buckets/default/collections/blog/records?_sort=-last_modified" --auth user:pass
HTTP/1.1 200 OK
Access-Control-Expose-Headers: Content-Length, Expires, Alert, Retry-After, Last-Modified, Total-Records, ETag, Pragma, Cache-Control, Backoff, Next-Page
Cache-Control: no-cache
Content-Length: 283
Content-Type: application/json; charset=UTF-8
Date: Wed, 10 Feb 2016 14:54:03 GMT
Etag: "1455115734732"
Last-Modified: Wed, 10 Feb 2016 14:48:54 GMT
Server: waitress
Total-Records: 3

{
    "data": [
        {
            "id": "8712d6c9-8caf-43d3-b70d-7c82d672a1bc", 
            "last_modified": 1455115734732, 
            "title": "art3"
        }, 
        {
            "id": "8aadb4d4-c107-4335-a119-81027143cf22", 
            "last_modified": 1455115734728, 
            "title": "art2"
        }, 
        {
            "id": "d914797f-1e55-4dde-ac92-51f4d06ba990", 
            "last_modified": 1455115734725, 
            "title": "art1"
        }
    ]
}

@leplatrem leplatrem changed the title Is the order of batch requests garanteed? Default order of records is not -last_modified Feb 10, 2016
@ayusharma
Copy link
Member

I want to work on this bug. I am able to reproduce the situation. Looking forward for suggestion to start.

@leplatrem leplatrem self-assigned this Feb 29, 2016
leplatrem added a commit that referenced this issue Mar 7, 2016
Upgrade to Cliquet 3 (fixes #345, fixes #fixes #369, fixes #421, fixes #424, fixes #433, fixes #434, fixes #461)
@leplatrem leplatrem modified the milestone: 1.12 Mar 8, 2016
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

2 participants