Diagram.restrict: apply Part conditions through the Master to preserve master-part compositional integrity
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
从 src/datajoint/diagram.py 中的 restrict 和 _propagate_restrictions(mode="restrict") 开始,然后将 _propagate_part_to_master 与 cascade 的向上遍历进行比较。验证现有的复现,并跟踪 Part 条件是如何传播的。完成的标准是:Part 限制能够选择符合条件的 Masters,同时每个被选中的 Master 保留其全部 Parts,且不改变 cascade 的删除行为。
由索引模型根据 Issue 内容生成。
描述
Summary
dj.Diagram.restrict is logically conjunctive (AND — it removes rows that fail the criteria).
Unlike the disjunctive trace/cascade (which include everything touched and keep/pull whole
compositional units), a conjunctive filter can cut into a master-part group, leaving partial
groups — a Master exported with only a subset of its Parts (or none). This preserves referential
integrity but breaks compositional integrity: the exported entity misrepresents the original.
Reproduction (structural)
dj.Diagram(schema).restrict(Master & 'm=1').restrict(Master.Part & 'p>3')
Master→ all ofm=1.Master.Part→ (Parts ofm=1, from the master-keyed downstream restriction) ANDp>3→ only
thep>3Parts.- Result:
Master m=1whole, but only a subset of its Parts. A Master can even survive with zero
Parts, sincerestrictdoes not walk up from Part to Master.
Why it matters
- Referential integrity — fine. A kept Part's FK to its Master is satisfied; a Master needs no Parts
to be valid. The export re-imports without dangling foreign keys. - Compositional integrity — broken. DataJoint's master-part contract treats a Master's Parts as one
atomic entity. A recording exported with only some of its channels loads cleanly but is a
corrupted/partial entity.
Root cause / model
In DataJoint's model the Master is the entity; Parts have no independent existence. The unit of
export is therefore the Master-with-all-its-Parts. A Part-level filter is either meaningless for export,
or should mean "Masters that have a matching Part."
Decision (v2.4)
In Diagram restriction, conditions on Part tables are applied through their Master:
- A restriction that selects Part rows lifts to an existential restriction on the Master — Masters
that have a matching Part are selected. - A selected Master brings in all of its Parts.
- Net: compositional units are never split; Parts are never filtered within a unit.
This is the compositional-integrity analogue, for read-only restriction/export, of what cascade's
part_integrity="cascade" does for delete.
Scope / relationships
- Not for 2.3.1 — behavior change deferred to v2.4.
- Distinct from #1500 (which established that
restrictdoes not performcascade's deletion
part→master walk-up). This issue is about filtering granularity — keeping units whole under a
conjunctive filter — a different mechanism; the two are compatible. - Optional 2.3.x stopgap: document the current behavior (restrict can yield partial Part groups; lift
Part criteria to the Master viaMaster & (Part & cond)).
References
- Surfaced in the 2.3.1
dj.Diagramreview (finding F12). - Code:
src/datajoint/diagram.py—restrict,_propagate_restrictions(mode="restrict"); contrast
_propagate_part_to_master(cascade's upward walk).
- 主要语言
- Python
- 星标
- 197
- 派生
- 98
- 平均合并
- 6 天 7 小时
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
datajoint/datajoint-python 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
datajoint/datajoint-python#1539 · 3 条评论 ·
-
dj.Diagram SVG output is not byte-reproducible: set iteration order leaks into node emission order 未关闭bug
难度 3/5 1-2 天 新手友好度 78/100
datajoint/datajoint-python#1551 ·
-
难度 5/5 一周以上 新手友好度 35/100
datajoint/datajoint-python#1550 ·
-
难度 5/5 一周以上 新手友好度 35/100
datajoint/datajoint-python#1547 ·
-
难度 4/5 3-5 天 新手友好度 52/100
datajoint/datajoint-python#1546 · 1 条评论 ·
查看 datajoint/datajoint-python 的全部 Issue
相似的 Issue
-
essnmx good first issue
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 条评论 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未关闭area: repo bug perceived difficulty: 2
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yeti-platform/yeti#1380 ·