diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-08-28 17:31:40 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-08-28 17:32:05 -0400 |
commit | 2008344aab70a9152ed23adb2b4c768fcb6103a4 (patch) | |
tree | 3a06b999dff514ef32f5105a550cf67c05675ba7 /lib/sqlalchemy/engine/reflection.py | |
parent | 573b542747103cd427db6770d29441dade4a278e (diff) | |
download | sqlalchemy-2008344aab70a9152ed23adb2b4c768fcb6103a4.tar.gz |
plus some more adjustments for mysql, or in general if an Index refers to
in-python only cols
Diffstat (limited to 'lib/sqlalchemy/engine/reflection.py')
-rw-r--r-- | lib/sqlalchemy/engine/reflection.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py index c1c546d84..458124893 100644 --- a/lib/sqlalchemy/engine/reflection.py +++ b/lib/sqlalchemy/engine/reflection.py @@ -470,6 +470,8 @@ class Inspector(object): fkeys = self.get_foreign_keys(table_name, schema, **tblkw) for fkey_d in fkeys: conname = fkey_d['name'] + # look for columns by orig name in cols_by_orig_name, + # but support columns that are in-Python only as fallback constrained_columns = [ cols_by_orig_name[c].key if c in cols_by_orig_name else c @@ -514,5 +516,11 @@ class Inspector(object): "Omitting %s KEY for (%s), key covers omitted columns." % (flavor, ', '.join(columns))) continue - sa_schema.Index(name, *[cols_by_orig_name[c] for c in columns], + # look for columns by orig name in cols_by_orig_name, + # but support columns that are in-Python only as fallback + sa_schema.Index(name, *[ + cols_by_orig_name[c] if c in cols_by_orig_name + else table.c[c] + for c in columns + ], **dict(unique=unique)) |