firebase / firebase/firebase-admin-python

Order diff between backend and client with order_by_key()

未關閉
#677 2 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
api: database
主要語言
Python
星號
1.2k
分支
359
平均合併
5 天 6 分鐘
30 天內合併 PR
2

描述

### Describe your environment

* Operating System version: macOS 12.4
* Firebase SDK version: 6.1.0
* Firebase Product: database
* Python version: 3.7.9
* Pip version: 21.3.1

### Describe the problem

When using order_by_key(), the order of the returned `OrderedDict` is not the same as the database making pagination very difficult

#### Steps to reproduce:

- Create a collection with this json in "/test" for example :
```
{
"123": {"myValue": true},
"100001": {"myValue": true},
"100002": {"myValue": true},
"100003": {"myValue": true},
"100004": {"myValue": true},
"100005": {"myValue": true}
}
```
- Query it with :
```python
db.reference("/test").order_by_key().limit_to_first(4).get()
```
- Comparison :

Current :
```
OrderedDict([('100001', {'myValue': True}), ('100002', {'myValue': True}), ('100003', {'myValue': True}), ('123', {'myValue': True})])
```
Expected :
```
OrderedDict([('123', {'myValue': True}), ('100001', {'myValue': True}), ('100002', {'myValue': True}), ('100003', {'myValue': True})])
```

#### Comments

So according to this [link](https://firebase.google.com/docs/database/admin/retrieve-data#orderbykey), order should be the same as the collection but in the corresponding `OrderedDict` the order is not the same so if you want make a pagination strategy, it just loops as getting the last key of the `OrderedDict` returned and using it in `start_at` will return the same result over and over again.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。