summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/schema.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-04-17 21:28:55 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-04-17 21:28:55 +0000
commit12f126f30bbad323b7e18cb704836252f3669e0f (patch)
tree2751decf8a192c3c9c8d314963e75932dffd5a87 /lib/sqlalchemy/schema.py
parentaabb6e530b05bee9cc5c2382a308a987abd6168e (diff)
downloadsqlalchemy-12f126f30bbad323b7e18cb704836252f3669e0f.tar.gz
slight cleanup for #498
Diffstat (limited to 'lib/sqlalchemy/schema.py')
-rw-r--r--lib/sqlalchemy/schema.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py
index ff835cec9..a0dd287e3 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