diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-07-21 11:44:31 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-07-21 11:44:31 -0400 |
| commit | c1295ce57ba7d906821b3ddd5b97aa9659700d52 (patch) | |
| tree | 029dc9f29647d2d2b7fcf138fcc0ab6face67786 /lib/sqlalchemy/schema.py | |
| parent | 06e84d5bcc0c009b8d4a91e7d247a25299e6c879 (diff) | |
| download | sqlalchemy-c1295ce57ba7d906821b3ddd5b97aa9659700d52.tar.gz | |
- Added an informative error message when
ForeignKeyConstraint refers to a column name in
the parent that is not found. Also in 0.6.9.
- add tests for [ticket:2226], as if we hit each @declared_attr
directly with obj.__get__(obj, name) instead of using
getattr(cls, name). Basic inheritance mechanics are improperly
used in this case, so 2226 is invalid.
Diffstat (limited to 'lib/sqlalchemy/schema.py')
| -rw-r--r-- | lib/sqlalchemy/schema.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 1763dc484..25c7e30a2 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -2008,7 +2008,13 @@ class ForeignKeyConstraint(Constraint): # string-specified column names now get # resolved to Column objects if isinstance(col, basestring): - col = table.c[col] + try: + col = table.c[col] + except KeyError: + raise exc.ArgumentError( + "Can't create ForeignKeyConstraint " + "on table '%s': no column " + "named '%s' is present." % (table.description, col)) if not hasattr(fk, 'parent') or \ fk.parent is not col: |
