datajoint-python
datajoint-python copied to clipboard
alter support for part tables
trafficstars
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
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
'''