diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-09-06 18:40:46 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-09-06 18:43:58 -0400 |
commit | 7afcb39a962d383e5ba04179c1b13131fb08a787 (patch) | |
tree | 266d62873e14f5a1466ec1f3fa373571bdcbd7f9 /lib/sqlalchemy/sql/schema.py | |
parent | fc48050e5d0c56fc5a6cd85679859e71961c59eb (diff) | |
download | sqlalchemy-7afcb39a962d383e5ba04179c1b13131fb08a787.tar.gz |
Catch set_parent_w_dispatch missing
Added an explicit error message for the case when objects passed to
:class:`.Table` are not :class:`.SchemaItem` objects, rather than resolving
to an attribute error.
Fixes: #4847
Change-Id: I4dcdcee86b64c85ccf12e2ddc3d638563d307991
Diffstat (limited to 'lib/sqlalchemy/sql/schema.py')
-rw-r--r-- | lib/sqlalchemy/sql/schema.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index d9667e445..69fc9408f 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -104,7 +104,15 @@ class SchemaItem(SchemaEventTarget, visitors.Visitable): for item in args: if item is not None: - item._set_parent_with_dispatch(self) + try: + spwd = item._set_parent_with_dispatch + except AttributeError: + raise exc.ArgumentError( + "'SchemaItem' object, such as a 'Column' or a " + "'Constraint' expected, got %r" % item + ) + else: + spwd(self) def get_children(self, **kwargs): """used to allow SchemaVisitor access""" |