Order diff between backend and client with order_by_key()

オープン
#677 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
database

調査の方向性

提供された JSON を使用して db.reference("/test").order_by_key().limit_to_first(4).get() で報告内容を再現し、OrderedDict の順序を Firebase の order_by_key の動作と比較してください。このクエリのレスポンス処理を追跡し、返されたキーがデータベースの順序を保持していることを確認して、start_at によるページネーションで結果が重複しないようにしてください。

索引モデルが issue の本文から書いたものです。

説明

api: database
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 :
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, 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.

主要言語
Python
スター
1.2k
フォーク
359
平均マージ
5日 6分
マージ済み PR(30日)
2

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

firebase/firebase-admin-python のほかの issue

firebase/firebase-admin-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。