Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug with del() #379

Closed
arsenyf opened this issue Jul 4, 2021 · 6 comments · Fixed by #386
Closed

bug with del() #379

arsenyf opened this issue Jul 4, 2021 · 6 comments · Fixed by #386
Labels
awaiting-triage Issues awaiting proper priority/milestone assignment. bug

Comments

@arsenyf
Copy link

arsenyf commented Jul 4, 2021

When attempting to delete I get the following error:

del(EXP2.Session & 'subject_id=481102')
Error using ~
Too many input arguments.

Error in dj.Relvar/del (line 95)
if ~fks.aliased

'subject_id' is the primary key for table EXP2.Session, and this always worked before. I noticed it after upgrading to DataJoint version 3.4.3.
del() with few other tables that are under EXP2.Session with the same key that I tested worked fine

MATLAB 2018b
DataJoint version 3.4.3

bug

@arsenyf arsenyf added awaiting-triage Issues awaiting proper priority/milestone assignment. bug labels Jul 4, 2021
@kabilar
Copy link
Collaborator

kabilar commented Aug 17, 2021

@kabilar @Alvalunasan

@Alvalunasan
Copy link
Contributor

Do we have any updates on this ?
Our team here in Princeton has been facing this issue a lot now.
Thanks

@kabilar
Copy link
Collaborator

kabilar commented Oct 21, 2021

Hi @Alvalunasan, thanks for the report. After discussion with @guzman-raphael, the team will be able to return to this issue within 2-3 weeks.

@zfj1
Copy link

zfj1 commented Jan 6, 2022

Just commenting here since this hasn't had any traction in a while. I believe this issue can be resolved with an edit to a single line of code, as in 938626c. This probably arose in the most recent release because of weak typing in MATLAB and testing against a table with only one foreign key. I haven't checked that the rest of the logic there is sound, but if you read the comments it's obvious this is what they were going for. So as a workaround before this gets formally addressed you should just be able to edit that line in your datajoint installation.

cnuahs added a commit to marmolab/datajoint-matlab that referenced this issue Jan 11, 2022
@Alvalunasan
Copy link
Contributor

Example of an incorrect deletion on version 3.4.2
table lab.DutyRoaster: (lab.User as foreign key many times)

%{
duty_roaster_date:  date       # date from which this assignment is valid.
----- 
(monday_duty)    -> lab.User(user_id)
(tuesday_duty)   -> lab.User(user_id)
(wednesday_duty) -> lab.User(user_id)
.
.
%}

testtech_del1 is a reference only for record 2 {'2021-03-11'}

lab.DutyRoaster

    DUTY_ROASTER_DATE       monday_duty         tuesday_duty        wednesday_duty      ...   
    _________________    _________________    _________________    _________________    ...

     {'2021-03-10'}      {'jrw10'        }    {'baptista'     }    {'jrw10'        }    ...
     {'2021-03-11'}      {'testtech_del1'}    {'testtech_del2'}    {'testtech_del1'}    ...

We try to delete that user it tries to delete all records from duty_roaster :

key.user_id = 'testtech_del1'
del(lab.User & key)

ABOUT TO DELETE:
       1 tuples from `u19_lab`.`user` (manual)
       2 tuples from `u19_lab`.`duty_roaster` (manual)

@kabilar
Copy link
Collaborator

kabilar commented Feb 5, 2022

Thanks @Alvalunasan. I will adapt your example for a test case.

Schema diagram

image

Table definitions

lab.User

%{
user_id: varchar(32)
%}

classdef User < dj.Manual
end

lab.Duty

%{
duty_date:  date
----- 
(duty_first)    -> lab.User(user_id)
(duty_second)    -> lab.User(user_id)
%}

classdef Duty < dj.Manual
end

Insert table entries

users = [{'user0'
          'user1'
          'user2'}]

insert(lab.User, users)

duty = [{'2020-01-01','user0','user1'},
        {'2020-12-31','user1','user2'}]

insert(lab.Duty, duty)

Table entries

lab.User()

     USER_ID 
    _________

    {'user0'}
    {'user1'}
    {'user2'}
lab.Duty()

      DUTY_DATE       duty_first    duty_second
    ______________    __________    ___________

    {'2020-01-01'}    {'user0'}      {'user1'} 
    {'2020-12-31'}    {'user1'}      {'user2'} 

Test case 1 with DataJoint MATLAB 3.4.2

Versions

MATLAB R2020b
DataJoint MATLAB 3.4.2
mym 2.8.2

  • Deleting user0 in lab.User, deletes all entries in lab.Duty table.
key.user_id = 'user0'
del(lab.User & key)

ABOUT TO DELETE:
       1 tuples from `kabilar_lab`.`user` (manual)
       2 tuples from `kabilar_lab`.`duty` (manual)

Proceed to delete? (yes/no) > yes
Deleting from lab.Duty
Deleting from lab.User
committed


lab.Duty()
0 tuples

Test case 2 with DataJoint MATLAB 3.4.3

Versions

MATLAB R2020b
DataJoint MATLAB 3.4.3
mym 2.8.2

  • Deleting user0 in lab.User, throws an error.
key.user_id = 'user0';
del(lab.User & key)

Error using  ~ 
Too many input arguments.

Error in dj.Relvar/del (line 95)
                            if ~fks.aliased

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-triage Issues awaiting proper priority/milestone assignment. bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants