datajoint/datajoint-matlab

correct cascaded deletes across renamed foreign keys

Opened this issue · 3 comments

correct cascaded deletes across renamed foreign keys

A more detailed description will follow.

@shenshan Can you describe a bit more one the use case you encountered around this? Did some testing on my side and I don't see this as an issue. The delete seems to cascade properly.

Hi @guzman-raphael , here is a toy example that reproduces the error:

Table designs:

%{
# parent table
parent_id:   int
-----
parent_value:   int
%}

classdef Parent < dj.Manual
end
%{
# child table
child_id:     int
-----
(parent) -> rename_fk.Parent
%}

classdef Child < dj.Manual
end

Insert entries:

insert(rename_fk.Parent, {1, 1; 2, 2; 3, 3})
insert(rename_fk.Child, {1, 1; 2, 2; 3, 3})

Delete one entry with parent_id = 1:

del(rename_fk.Parent & 'parent_id=1')

It should only delete one entry from Child, but it comes out like this:

ABOUT TO DELETE:
       1 tuples from `rename_fk`.`parent` (manual)
       3 tuples from `rename_fk`.`child` (manual)

Proceed to delete? (yes/no) >