Skip to content

fix(cascade): restrict only the rows a cascade reaches (2.3) - #1593

Open
dimitri-yatsenko wants to merge 1 commit into
maint/2.3from
fix/cascade-overdelete-2.3
Open

dimitri-yatsenko wants to merge 1 commit into
maint/2.3from
fix/cascade-overdelete-2.3

Conversation

@dimitri-yatsenko

Copy link
Copy Markdown
Member

Cherry-pick of #1592 onto maint/2.3, which starts at v2.3.4, for the v2.3.5 patch release.

Closes #1589, closes #1590, closes #1591 on the 2.3 line. The same commit (cherry picked from 18e56492) applies cleanly to v2.3.4. See #1592 for the description.

v2.3.5 contains only this fix. The other changes on master since v2.3.4 ship in v2.4.0.

Three cases deleted rows outside the cascade:

- `(T & dj.Top(n)).delete()` and `delete_quick()` ignored the Top and
  deleted every row matching the other conditions. A Top seed is now
  replaced by the primary keys it selects.
- A parent restriction was copied to a child whenever the restricted
  attributes were in the child's primary key. Through a nullable foreign
  key that shares a primary-key column, the copy also deleted child rows
  whose foreign key is NULL; in a diamond it missed rows. The copy now
  applies only when the restricted attributes are among the foreign key's
  attributes and the foreign key lies in the child's primary key.
  Otherwise the child is restricted by the projected parent.
- With part_integrity="cascade", the part-to-master lift copied the
  part's condition to the master, which also deleted masters with no
  matching part rows. The master is now restricted by the restricted
  part, so a master joins the cascade only if one of its part rows did.
  The walk's restrictions on intermediate parts are restored once the
  master is materialized; the master cascades back to all of its parts.

The Diagram copy constructor now copies each node's restriction list
instead of deep-copying projected query expressions, which hold a live
connection.

(cherry picked from commit 18e5649)
@dimitri-yatsenko dimitri-yatsenko added this to the v2.3.5 milestone Oct 17, 2026
@dimitri-yatsenko dimitri-yatsenko added the bug Indicates an unexpected problem or unintended behavior label Oct 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Indicates an unexpected problem or unintended behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant