@@ -34,17 +34,13 @@ def build_foreign_key_parser_old():
3434
3535
3636def build_foreign_key_parser ():
37- left = pp .Literal ('(' ).suppress ()
38- right = pp .Literal (')' ).suppress ()
39- attribute_name = pp .Word (pp .srange ('[a-z]' ), pp .srange ('[a-z0-9_]' ))
40- new_attrs = pp .Optional (left + pp .delimitedList (attribute_name ) + right ).setResultsName ('new_attrs' )
4137 arrow = pp .Literal ('->' ).suppress ()
4238 lbracket = pp .Literal ('[' ).suppress ()
4339 rbracket = pp .Literal (']' ).suppress ()
4440 option = pp .Word (pp .srange ('[a-zA-Z]' ))
4541 options = pp .Optional (lbracket + pp .delimitedList (option ) + rbracket ).setResultsName ('options' )
4642 ref_table = pp .restOfLine .setResultsName ('ref_table' )
47- return new_attrs + arrow + options + ref_table
43+ return arrow + options + ref_table
4844
4945
5046def build_attribute_parser ():
@@ -96,16 +92,16 @@ def compile_foreign_key(line, context, attributes, primary_key, attr_sql, foreig
9692 from .table import Table
9793 from .query import Projection
9894
99- new_style = False # See issue #436. Old style to be deprecated in a future release
95+ new_style = True # See issue #436. Old style to be deprecated in a future release
10096 try :
101- result = foreign_key_parser_old .parseString (line )
102- except pp .ParseException as err :
97+ result = foreign_key_parser .parseString (line )
98+ except pp .ParseException :
10399 try :
104- result = foreign_key_parser .parseString (line )
100+ result = foreign_key_parser_old .parseString (line )
105101 except pp .ParseBaseException as err :
106- raise DataJointError ('Parsing error in line "%s". %s.' % (line , err ))
102+ raise DataJointError ('Parsing error in line "%s". %s.' % (line , err )) from None
107103 else :
108- new_style = True
104+ new_style = False
109105 try :
110106 ref = eval (result .ref_table , context )
111107 except Exception if new_style else NameError :
@@ -129,7 +125,7 @@ def compile_foreign_key(line, context, attributes, primary_key, attr_sql, foreig
129125
130126 # check that dependency is of supported type
131127 if (not isinstance (ref , (Table , Projection )) or len (ref .restriction ) or
132- (isinstance (ref , Projection ) and (not isinstance (ref ._arg , Table ) or not len (ref ._arg .restriction )))):
128+ (isinstance (ref , Projection ) and (not isinstance (ref ._arg , Table ) or len (ref ._arg .restriction )))):
133129 raise DataJointError ('Dependency "%s" is not supported (yet). Use a base table or its projection.' %
134130 result .ref_table )
135131
0 commit comments