Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Cannot chain first and last on collection #201

Open
UncleGene opened this issue May 22, 2012 · 3 comments
Open

Cannot chain first and last on collection #201

UncleGene opened this issue May 22, 2012 · 3 comments

Comments

@UncleGene
Copy link

Model.all.first(3).last returns last element of the whole collection, not expected third element

@dkubb
Copy link
Member

dkubb commented May 23, 2012

It's possible that the method that handles "windowing" of the query is calculating things incorrectly.

After #first(3) the offset should be 0, and the limit should be 3. After #last, the offset should be changed to 2 and the limit changed to 1. I'm not sure what the value is (will need to look more deeply), but it's likely the problem.

The way queries are composed in DM1 may limit how far this can be fixed without breaking other use cases. I can confirm though that this problem does not exist in Veritas/DM2 due to how queries are composed.

@UncleGene
Copy link
Author

In current code, last slices reversed query - and, thus, any chaining of last breaks slice offset/limit adjustment.

This looks connected to other bug report (no support for negative values in slice), if latter is fixed - former fix is trivial.

@UncleGene
Copy link
Author

First step towards fix submitted as pull request
#202

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants