Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Order diff between backend and client with order_by_key()

未关闭
#677 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
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 分钟
30 天内合并 PR
2

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-admin-python 的其他 Issue

查看 firebase/firebase-admin-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。