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

json-type tutorial teaches client-side filtering as a property of JSON

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

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
jupyter-notebook, python
领域
documentation

调研方向

This work is in src/tutorials/advanced/json-type.ipynb and is blocked on datajoint/datajoint-python#1564. After that issue merges, read the filtering reference added in #291, then update the “Filtering on JSON Content” section and Design Guidelines table. Re-execute the notebook so its committed outputs match, and cross-link the reference.

由索引模型根据 Issue 内容生成。

描述

documentation

Blocked on datajoint/datajoint-python#1564. Deliberately deferred so the tutorial is not rewritten twice.

The problem

src/tutorials/advanced/json-type.ipynb is the page a user opens to learn how to work with JSON. Its filtering section reads:

Filtering on JSON Content

Fetch then filter in Python:

followed by pulling the whole table into a list comprehension:

calibrated = [
    e for e in Equipment.to_dicts()
    if e['specs'] and e['specs'].get('calibrated')
]

and its Design Guidelines table lists this as an inherent property of the type:

JSON Normalized Tables
Filter in Python Filter in SQL

Why it is wrong

Server-side filtering works, on both backends. Equipment & {"specs.vendor": "Acme"} is translated to json_value() on MySQL and jsonb_extract_path_text() on PostgreSQL; ordering comparisons work through a typed projection, proj(ch="specs.channels:unsigned") & "ch > 32". The syntax is documented in #291.

So the tutorial teaches a full table scan into Python for something the database does, and presents it as a limitation of JSON rather than a choice.

Why it probably says that

The tutorial's own example is specs.calibrated, a boolean — and & {"specs.calibrated": True} returns no rows on MySQL and raises on PostgreSQL (datajoint-python#1564). Whoever wrote the section likely tried exactly that, got nothing back, and concluded JSON cannot be filtered server-side.

That is why this waits: writing the section against the string workaround ({"specs.calibrated": "true"}) would teach an idiom that becomes wrong as soon as #1564 lands.

When #1564 merges

  1. Rewrite Filtering on JSON Content to filter server-side, keeping one short client-side example for genuinely non-SQL-expressible predicates.
  2. Correct the Design Guidelines table — "Filter in Python" is not a property of JSON. The honest contrast is about indexing and type enforcement, not about where filtering happens.
  3. Cross-link the reference section added in #291.
  4. Re-execute the notebook: these are code cells with committed outputs.
主要语言
Jupyter Notebook
星标
7
派生
12
平均合并
2 天 19 小时
30 天内合并 PR
20

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

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

datajoint/datajoint-docs 的其他 Issue

查看 datajoint/datajoint-docs 的全部 Issue

相似的 Issue

更多 Documentation Issue

把新 issue 发到你的邮箱

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