override columns with ForeignKey dupes existing foreign key

Issue #728 resolved
Mike Bayer repo owner created an issue
table = Table('mytable', meta,
   Column('id', Integer, ForeignKey('othertable.id'), primary_key=True),
   autoload=True
)

if the actual table has the same foreign key, youll get a "foreign keys" collection like

OrderedSet([ForeignKey(u'account_ids.account_id'),
ForeignKey('account_ids.account_id')](ForeignKey(u'account_ids.account_id'),
ForeignKey('account_ids.account_id')))

Comments (3)

  1. jek

    this is related to #650. basically what is needed is a remove() that removes a column and its participation in all schema items, some of which reference the Column object and some of which are only by name at this point in autoload.

  2. Mike Bayer reporter

    fbd0a0c725249ef22260a3714ed564a191c0c45c

    Im wondering if reversing the order of operations simplfies this; load local Column objects first, then issue exclude_columns to the reflection process. Problem is, if a table is auto-reflected via a foreign key, then you cant redefine those columns (since the idea is to explicitly forbid "redefinition" of columns). Weirdly, issuing a Table constructor for an already-reflected table requires the "use_existing" flag, which is only documented in docstrings; id think we'd have 100s of irc and email queries about this but we don't...which implies that somehow, everyone whos using reflection somehow does not ever come across an auto-reflected table ?? that seems a little weird.

  3. Log in to comment