Open UncleGene opened 12 years ago
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.
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.
First step towards fix submitted as pull request https://github.com/datamapper/dm-core/issues/202
Model.all.first(3).last returns last element of the whole collection, not expected third element