From: Mike Bayer Date: Tue, 17 Apr 2007 21:28:55 +0000 (+0000) Subject: slight cleanup for #498 X-Git-Tag: rel_0_3_7~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12f126f30bbad323b7e18cb704836252f3669e0f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git slight cleanup for #498 --- diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index ff835cec93..a0dd287e33 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -707,12 +707,15 @@ class ForeignKey(SchemaItem): table = Table(tname, parenttable.metadata, mustexist=True, schema=schema) try: if colname is None: + # colname is None in the case that ForeignKey argument was specified + # as table name only, in which case we match the column name to the same + # column on the parent. key = self.parent self._column = table.c[self.parent.key] else: self._column = table.c[colname] except KeyError, e: - raise exceptions.ArgumentError("Could not create ForeignKey '%s' on table '%s': table '%s' has no column named '%s'" % (self._colspec, parenttable.name, table.name, e.args[0])) + raise exceptions.ArgumentError("Could not create ForeignKey '%s' on table '%s': table '%s' has no column named '%s'" % (self._colspec, parenttable.name, table.name, str(e))) else: self._column = self._colspec # propigate TypeEngine to parent if it didnt have one