autogenerate breaks on fk specified on remote name when remote key != name #456
Comments
Changes by dataradiant (@dataradiant):
|
Michael Bayer (@zzzeek) wrote: here's the funniest part of that function:
then try to resolve the remote table and adjust for column.keywhat a letdown. as for the issue, need a reproducer. Guess this is just the render() operation. |
Michael Bayer (@zzzeek) wrote: the two options here would be either to also replicate the "link_to_name=True" flag if we are still linking to name, or to replace the name with the key if we've resolved it. |
Michael Bayer (@zzzeek) wrote: nevermind, i recall we are just trying to render for DB-direct operations only |
Michael Bayer (@zzzeek) wrote: |
Changes by Michael Bayer (@zzzeek):
|
Michael Bayer (@zzzeek) wrote: Clean up _fk_colspec() for link_to_name, no column found A :class: Change-Id: Ic030fbc106973231b6877c1acfb5349e515335a8 → 0a0524d |
Changes by Michael Bayer (@zzzeek):
|
Migrated issue, originally created by dataradiant (@dataradiant)
I have a foreign key where the remote column is referenced by name and
link_to_name=True
. When using autogenerate, I receive a KeyError on the column name here: https://bitbucket.org/zzzeek/alembic/src/feaea56b97a11f4f132fb5f55d8a6b71dc0b9c04/alembic/autogenerate/render.py?at=master&fileviewer=file-view-default#render.py-685It's trying to lookup the column using the string provided, which in this case is the name rather than the key, which obviously doesn't work so well when they aren't the same.
Replacing that line with a conditional that checks for
link_to_name
seems to work at least for my case:The text was updated successfully, but these errors were encountered: