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

Cannot do foreign key renaming for multiple fields coming from different original parent table in 3.4.1 #347

Open
shenshan opened this issue Feb 4, 2021 · 1 comment
Labels
Milestone

Comments

@shenshan
Copy link

shenshan commented Feb 4, 2021

Cannot declare a table with foreign key renaming for multiple fields

Reproducibility

Include:

  • OS MACOS
  • MATLAB Version 2020a
  • MySQL version 10.4.13-MariaDB Homebrew
  • MySQL Deployment Strategy local-native
  • DataJoint Version 3.4.1
  • Minimum number of steps to reliably reproduce the issue:
%{
pk_a:  varchar(12)
%}

classdef A < dj.Manual
end
%{
pk_b : varchar(12)
%}

classdef B < dj.Manual
end
%{
-> subject.A
-> subject.B
%}

classdef C < dj.Manual
end
%{
(pk_da, pk_db) -> subject.C
%}

classdef D < dj.Manual
end
  • Complete error stack as a result of evaluating the above steps
    When declaring D, I got the following error:
>> subject.D

ans = 


Object subject.D

Error using dj.internal.Declare.makeFK (line 304)
Mapped fields (pk_da,pk_db) and () must match in the foreign key.

Error in dj.internal.Declare.declare (line 152)
                            dj.internal.Declare.makeFK( ...

Error in dj.internal.Table/create (line 624)
            [sql, external_stores] = dj.internal.Declare.declare(self, def);

Error in dj.internal.Table/get.plainTableName (line 116)
                self.create

Error in dj.internal.Table/get.tableHeader (line 83)
                self.tableHeader = self.schema.headers(self.plainTableName);

Error in dj.internal.GeneralRelvar/compile (line 676)
                    header = derive(tab.tableHeader);

Error in dj.internal.GeneralRelvar/get.header (line 43)
            header = self.compile;

Error in dj.internal.GeneralRelvar/disp (line 73)
            hdr = self.header;

If I do

%{
pk1: varchar(12)
pk2: varchar(12)
%}

classdef A < dj.Manual
end
%{
(f1, f2) -> subject.A(pk1, pk2)
%}
classdef B < dj.Manual
end

It worked.

@shenshan shenshan added bug awaiting-triage Issues awaiting proper priority/milestone assignment. labels Feb 4, 2021
@shenshan
Copy link
Author

shenshan commented Feb 4, 2021

Tried two more cases, good to be added to the test cases.

This works:

%{
pk_a:  varchar(12)
%}

classdef A < dj.Manual
end
%{
-> subject.A
pk_b:  varchar(12)
%}

classdef B < dj.Manual
end
%{
(pk_ca, pk_cb) -> subject.B
%}

classdef C < dj.Manual
end

This does not:

%{
pk_a:  varchar(12)
%}

classdef A < dj.Manual
end
%{
-> subject.A
pk_b:  varchar(12)
%}

classdef B < dj.Manual
end
%{
-> subject.B
%}

classdef C < dj.Manual
end
%{
(pk_da, pk_db)-> subject.C(pk_a, pk_b)
%}

classdef D < dj.Manual
end

It gave error:

Mapped fields (pk_da,pk_db) and () must match in the foreign key.

Error in dj.internal.Declare.declare (line 152)
                            dj.internal.Declare.makeFK( ...

Error in dj.internal.Table/create (line 624)
            [sql, external_stores] = dj.internal.Declare.declare(self, def);

Error in dj.internal.Table/get.plainTableName (line 116)
                self.create

Error in dj.internal.Table/get.tableHeader (line 83)
                self.tableHeader = self.schema.headers(self.plainTableName);

Error in dj.internal.GeneralRelvar/compile (line 676)
                    header = derive(tab.tableHeader);

Error in dj.internal.GeneralRelvar/get.header (line 43)
            header = self.compile;

Error in dj.internal.GeneralRelvar/disp (line 73)
            hdr = self.header;

@guzman-raphael guzman-raphael added this to the Release 3.4.3 milestone Mar 24, 2021
@guzman-raphael guzman-raphael removed the awaiting-triage Issues awaiting proper priority/milestone assignment. label Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants