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

Update foreign key definition syntax to match newer convention #350

Open
guzman-raphael opened this issue Feb 22, 2021 · 1 comment
Open

Comments

@guzman-raphael
Copy link
Collaborator

Feature Request

Problem

Foreign key definition does not match newer syntax implemented in datajoint-python.

Currently it observes:

(new_attr1, new_attr2) -> [nullable, unique] ClassName.TableName(old_attr1, old_attr2)

Expected to accept:

-> [nullable, unique] ClassName.TableName.proj('old_attr1->new_attr1', 'old_attr2->new_attr2')

Requirements

Ensure the above expected syntax is respected.

Justification

Feature parity with datajoint-python.

@guzman-raphael guzman-raphael added enhancement awaiting-triage Issues awaiting proper priority/milestone assignment. labels Feb 22, 2021
@gyellen
Copy link

gyellen commented Mar 17, 2021

The python syntax is (according to the documentation)
-> Table.project(new_attr='old_attr')
so I'm assuming that the analogous syntax in MATLAB is
-> [nullable, unique] ClassName.TableName.proj(new_attr1='old_attr1', new_attr2='old_attr2')

This matches the current Python syntax for sql math (as in the autoincrement example for primary keys)
next='max(scan_idx)+1'
though the syntax in Raphael's comment above better matches the current working syntax for autoincrement in MATLAB:
key.scan_idx = fetch1(Scan & key, 'max(scan_idx)+1 -> next')

The table definition syntax is more flexible than the syntax for executable MATLAB code, because it is interpreted by the DJ Toolbox parser (from the block comment) rather than the MATLAB language parser. So the new='old' format can work in the table definition in MATLAB, but the next='max(scan_idx)+1' will not work in executable code.

Probably worth a discussion before the individual cases get handled differently...

@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
Projects
None yet
Development

No branches or pull requests

2 participants