Repository navigation
fix(diagram): copy a restriction to a related table only when its attributes are known exactly - #1758
Open
dimitri-yatsenko wants to merge 1 commit into
Open
dimitri-yatsenko wants to merge 1 commit into
dimitri-yatsenko wants to merge 1 commit into
Conversation
…ributes are known exactly Cascade, restrict and trace copy a restriction from one table to the next when its attributes lie within the foreign key. The attributes of a string condition are parsed from its SQL text, so they are not known exactly. A restriction with a string condition anywhere in it now propagates through the related rows (the projection rule) instead of being copied. Dict, key and query restrictions, and restrictions produced by propagation, are copied as before.
dimitri-yatsenko
requested review from
MilagrosMarin,
lum-agilyti and
ttngu207
November 25, 2026 00:24
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1757.
Summary
Diagram.cascade,Diagram.restrictandDiagram.tracecopy a restriction to a related table when its attributes lie within the foreign key. A string condition's attributes are parsed from its SQL text, so they may be incomplete. With this change, a restriction that contains a string condition anywhere propagates through the related rows instead of being copied.condition.py:make_conditionmarks a restriction's attribute set as inexact whenever a string condition contributes to it, including strings nested in AND, OR and NOT lists.expression.py: each query carries that mark (private_restriction_attributes_exact).diagram.py: each diagram records which nodes' restrictions are inexact. The copy rule, downward and upward, applies only to exact ones, and everything else uses the projection rule. A seed replaced by its keys (dj.Top, or a restriction by another query) is exact.Behavior:
self.upstreamis unchanged.IN (SELECT …)subquery where they used a copied condition. Rows are selected exactly through the referenced rows.tracefrom a string seed now selects only the parents that the seed rows reference.No public API is added.
extract_column_namesand the generated SQL for each condition are unchanged.Tests
New integration tests in
test_cascade_overdelete.py, on MySQL and PostgreSQL, using two string forms the parser reads incompletely:part_integrity="cascade";The 12 string-form tests fail without the change. The full suite passes: 2071 passed, 17 skipped.