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

alter support for part tables #936

Closed
ixcat opened this issue Jul 28, 2021 · 1 comment · Fixed by #991
Closed

alter support for part tables #936

ixcat opened this issue Jul 28, 2021 · 1 comment · Fixed by #991
Labels
Milestone

Comments

@ixcat
Copy link
Contributor

ixcat commented Jul 28, 2021

Bug Report

Description

Alter on part tables yields 'datajoint.errors.DataJointError: Foreign key reference master could not be resolved'

Reproducibility

Via support ticket 151 ; reproduced on linux / dj 0.13.3 / py 3.8 using:

import datajoint as dj

schema = dj.schema('test_fooparts')

@schema
class Foo(dj.Manual):
    definition = '''
    foo_id: int
    '''

    class SubFooOne(dj.Part):
        definition = '''
        -> master
        subfoo_id: int
        '''

followed by:

>>> Foo.SubFooOne().alter()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/src/djc/datajoint-python/datajoint/table.py", line 104, in alter
    sql, external_stores = alter(self.definition, old_definition, context)
  File "/src/djc/datajoint-python/datajoint/declare.py", line 360, in alter
    table_comment, primary_key, attribute_sql, foreign_key_sql, index_sql, external_stores = prepare_declare(
  File "/src/djc/datajoint-python/datajoint/declare.py", line 248, in prepare_declare
    compile_foreign_key(line, context, attributes,
  File "/src/djc/datajoint-python/datajoint/declare.py", line 143, in compile_foreign_key
    raise DataJointError('Foreign key reference %s could not be resolved' % result.ref_table)
datajoint.errors.DataJointError: Foreign key reference master could not be resolved

Expected Behavior

Unclear if master/part support is included in alter yet (alter is experimental); filing for reference to track capability

@rly
Copy link
Contributor

rly commented Feb 9, 2022

A workaround for this is to not use the "master" keyword in the Part table definition and instead reference the name of the master table. e.g., in your example:

        definition = '''
        -> Foo  # instead of master
        subfoo_id: int
        '''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants