octabytes / FireO

Google Cloud Firestore modern and simplest convenient ORM package in Python. FireO is specifically designed for the Google's Firestore
https://fireo.octabyte.io
Apache License 2.0
247 stars 29 forks source link

Cursor and Ordering #211

Closed turksoyomer closed 1 year ago

turksoyomer commented 1 year ago

When you generate cursor from collection with descending ordering, the generated cursor consists with ascending ordering.

For example, let's consider we have Comment collection with some fields and "created_time" field as DateTime.

collection = Comment.collection.order("-created_time").fetch(5) comments = list(collection) cursor = collection.cursor

If you decode the cursor you will see a dictionary with some parameters, like last_doc, limit, filters if you used, and order. But if you look at the order closely, it will generate order="created_time" not "-created_time". And this causes problems with next fetch.

I wrote an function to correct the cursor in my project, but maybe it will be much safer when we fix this issue inside fireo package.

ADR-007 commented 1 year ago

Thank you for the report! The fix is here This fix will be available in the next release v2.2.0 when @AxeemHaider releases it