@@ -177,19 +177,14 @@ def compile_foreign_key(
177177 from .table import Table
178178 from .expression import QueryExpression
179179
180- obsolete = False # See issue #436. Old style to be deprecated in a future release
181180 try :
182181 result = foreign_key_parser .parseString (line )
183- except pp .ParseException :
184- try :
185- result = foreign_key_parser_old .parseString (line )
186- except pp .ParseBaseException as err :
187- raise DataJointError ('Parsing error in line "%s". %s.' % (line , err ))
188- else :
189- obsolete = True
182+ except pp .ParseException as err :
183+ raise DataJointError ('Parsing error in line "%s". %s.' % (line , err ))
184+
190185 try :
191186 ref = eval (result .ref_table , context )
192- except NameError if obsolete else Exception :
187+ except Exception :
193188 raise DataJointError (
194189 "Foreign key reference %s could not be resolved" % result .ref_table
195190 )
@@ -205,18 +200,6 @@ def compile_foreign_key(
205200 'Primary dependencies cannot be nullable in line "{line}"' .format (line = line )
206201 )
207202
208- if obsolete :
209- logger .warning (
210- 'Line "{line}" uses obsolete syntax that will no longer be supported in datajoint 0.14. '
211- "For details, see issue #780 https://github.com/datajoint/datajoint-python/issues/780" .format (
212- line = line
213- )
214- )
215- if not isinstance (ref , type ) or not issubclass (ref , Table ):
216- raise DataJointError (
217- "Foreign key reference %r must be a valid query" % result .ref_table
218- )
219-
220203 if isinstance (ref , type ) and issubclass (ref , Table ):
221204 ref = ref ()
222205
@@ -232,55 +215,6 @@ def compile_foreign_key(
232215 % result .ref_table
233216 )
234217
235- if obsolete :
236- # for backward compatibility with old-style dependency declarations. See issue #436
237- if not isinstance (ref , Table ):
238- DataJointError (
239- 'Dependency "%s" is not supported. Check documentation.'
240- % result .ref_table
241- )
242- if not all (r in ref .primary_key for r in result .ref_attrs ):
243- raise DataJointError ('Invalid foreign key attributes in "%s"' % line )
244- try :
245- raise DataJointError (
246- 'Duplicate attributes "{attr}" in "{line}"' .format (
247- attr = next (attr for attr in result .new_attrs if attr in attributes ),
248- line = line ,
249- )
250- )
251- except StopIteration :
252- pass # the normal outcome
253-
254- # Match the primary attributes of the referenced table to local attributes
255- new_attrs = list (result .new_attrs )
256- ref_attrs = list (result .ref_attrs )
257-
258- # special case, the renamed attribute is implicit
259- if new_attrs and not ref_attrs :
260- if len (new_attrs ) != 1 :
261- raise DataJointError (
262- 'Renamed foreign key must be mapped to the primary key in "%s"'
263- % line
264- )
265- if len (ref .primary_key ) == 1 :
266- # if the primary key has one attribute, allow implicit renaming
267- ref_attrs = ref .primary_key
268- else :
269- # if only one primary key attribute remains, then allow implicit renaming
270- ref_attrs = [attr for attr in ref .primary_key if attr not in attributes ]
271- if len (ref_attrs ) != 1 :
272- raise DataJointError (
273- 'Could not resolve which primary key attribute should be referenced in "%s"'
274- % line
275- )
276-
277- if len (new_attrs ) != len (ref_attrs ):
278- raise DataJointError ('Mismatched attributes in foreign key "%s"' % line )
279-
280- if ref_attrs :
281- # convert to projected dependency
282- ref = ref .proj (** dict (zip (new_attrs , ref_attrs )))
283-
284218 # declare new foreign key attributes
285219 for attr in ref .primary_key :
286220 if attr not in attributes :
0 commit comments