Defect in ForeignKeys on PrimaryKey columns.

Issue #1399 resolved
Former user created an issue

When creating a FK object, the column argument can be passed in as class.column, a string, or class.table.c.column. However, if the column the FK is created on is a primary key, using class.column raises an attribute error:

AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object has an attribute 'table'

The attached file shows a working FK using class.column (third class), and a defective fourth class that attempts to create a FK on a column that is also a PK using class.column. In the example, the PK is a composite of two columns, however this is not the issue, the code was tested and raised the same error without the second column.

In the example, changing class.column for one of the other options listed above resolved the problem. This is not a serious defect as the other mechanisms work fine, but if this is a relatively easy fix it is worth doing as it provides more elegant syntax which is already working for the most part.

Comments (3)

  1. Log in to comment