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
docs: update diagram spec for Diagram.cascade() classmethod API
- cascade() is now a classmethod: Diagram.cascade(table_expr)
- Update all code examples (no intermediate dj.Diagram(schema) step)
- restrict() constraint: "cannot be called on cascade Diagram"
- prune() constraint: raises on cascade Diagrams (race condition safety)
- counts() requires Diagram.cascade() or restrict()
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Operational methods (`cascade`, `restrict`, `counts`, `prune`) were added in DataJoint 2.2.
123
+
Operational methods (`Diagram.cascade()`, `restrict`, `counts`, `prune`) were added in DataJoint 2.2.
124
124
125
125
Diagrams can propagate restrictions through the dependency graph and inspect affected data using the graph structure. These methods turn Diagram from a visualization tool into a graph computation and inspection component. All mutation operations (delete, drop) are executed by `Table.delete()` and `Table.drop()`, which use Diagram internally.
Prepare a cascading delete. Starting from a restricted table expression, propagate the restriction downstream through all descendants using **OR** semantics — a descendant row is marked for deletion if *any* ancestor path reaches it. The returned Diagram is **trimmed** to the cascade subgraph: only the seed table and its descendants remain; all ancestors and unrelated tables are removed. The trimmed diagram is ready for `counts()` and `delete()`.
133
+
Create a cascade diagram for delete. Builds a complete dependency graph from the table expression, includes all descendants across all loaded schemas, propagates the restriction downstream using **OR** semantics — a descendant row is marked for deletion if *any* ancestor path reaches it — and **trims** to the cascade subgraph.
134
134
135
135
| Parameter | Type | Default | Description |
136
136
|-----------|------|---------|-------------|
@@ -139,12 +139,6 @@ Prepare a cascading delete. Starting from a restricted table expression, propaga
139
139
140
140
**Returns:** New `Diagram` containing only the seed table and its descendants, with cascade restrictions applied.
141
141
142
-
**Constraints:**
143
-
144
-
-**One-shot** — can only be called once on an unrestricted Diagram
145
-
- Mutually exclusive with `restrict()`
146
-
-`table_expr.full_table_name` must be a node in the diagram
147
-
148
142
**`part_integrity` values:**
149
143
150
144
| Value | Behavior |
@@ -156,9 +150,8 @@ Prepare a cascading delete. Starting from a restricted table expression, propaga
156
150
With `"cascade"`, the restriction flows **upward** from a part table to its master: the restricted part rows identify which master rows are affected, those masters receive a restriction, and that restriction propagates back downstream through the normal cascade — deleting the entire compositional unit (master + all parts), not just the originally matched part rows.
Remove tables with zero matching rows from the diagram view. This only affects the diagram object — no tables or data are modified in the database. Without prior restrictions, removes physically empty tables from the diagram. With restrictions (`cascade()` or `restrict()`), removes tables where the restricted query yields zero rows.
208
+
Remove tables with zero matching rows from the diagram view. This only affects the diagram object — no tables or data are modified in the database. Without prior restrictions, removes physically empty tables from the diagram. After `restrict()`, removes tables where the restricted query yields zero rows.
218
209
219
210
**Returns:** New `Diagram` with empty tables removed.
220
211
212
+
**Constraints:** Cannot be used on a Diagram produced by `Diagram.cascade()`. Cascade diagrams must retain all descendant tables because a table empty at cascade time could have rows by the time `delete()` executes.
213
+
221
214
**Note:** Queries the database to determine row counts. The underlying graph structure is preserved — subsequent `restrict()` calls can still seed at any table in the schema.
0 commit comments