Skip to content

Commit 5e40c87

Browse files
Add test for Part.delete kwargs pass-through
Verify that kwargs like transaction=False can be passed to Part.delete and forwarded to Table.delete, enabling use within external transactions. Tests #1276 Co-authored-by: dimitri-yatsenko <dimitri@datajoint.com>
1 parent 9052492 commit 5e40c87

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/test_cascading_delete.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,23 @@ def test_delete_1159(thing_tables):
146146

147147
assert len(tbl_a) == 6, "Failed to cascade restriction attributes"
148148
assert len(tbl_e) == 3, "Failed to cascade restriction attributes"
149+
150+
151+
def test_part_delete_kwargs_passthrough(schema_simp_pop):
152+
"""Test issue #1276: Part.delete should pass kwargs through to Table.delete.
153+
154+
This test verifies that kwargs like transaction=False can be passed to
155+
Part.delete, enabling use within external transactions.
156+
"""
157+
assert B.C(), "Part table B.C should have data"
158+
initial_count = len(B.C())
159+
160+
# Use an external transaction and pass transaction=False to Part.delete
161+
with B.C().connection.transaction:
162+
# Restrict to a single entry and delete with transaction=False
163+
restricted = B.C() & "id_a=0 AND id_b=0 AND id_c=0"
164+
if restricted:
165+
restricted.delete(force=True, transaction=False)
166+
167+
# Verify deletion occurred
168+
assert len(B.C()) < initial_count, "Part.delete with transaction=False should work"

0 commit comments

Comments
 (0)