You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
part_integrity="cascade" deletes masters that have no matching part rows #1591
With part_integrity="cascade", deleting part rows can delete masters that have no matching part rows, together with everything downstream of those masters.
@schemaclassMaster(dj.Manual):
definition=""" master_id : int32 """classP(dj.Part):
definition=""" -> master p_id : int32 """Master.insert([(1,), (2,)])
Master.P.insert([(1, 1)]) # master 2 has no parts
(Master.P& [{"master_id": 1}, {"master_id": 2}]).delete(prompt=False, part_integrity="cascade")
len(Master()) # 0 — expected 1: master 2 had no matching part row
Cause. The part-to-master lift copies the part's condition to the master whenever the restricted attributes are in the master's primary key (Diagram._apply_propagation_rule_upward, Rule 1). That selects every master satisfying the condition, not the masters of the part rows that matched.
Workaround until the fix ships: restrict the parts by keys that exist, e.g. Master.P & (Master.P & cond).keys(), or use the default part_integrity="enforce".
Fix: the lift restricts the master by the restricted part, master & part_restricted.proj(...), so a master joins the cascade only if one of its part rows did.
Activity