diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-07-08 15:07:44 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-07-08 15:07:44 +0000 |
| commit | b330ffbc13ddb4274a004eab6a13ce40d641e555 (patch) | |
| tree | 88605188d6adac26c77defa544fc5cde208952f5 /lib/sqlalchemy/sql/base.py | |
| parent | a6d8b674e92ef1cabdb2ab85490397f3ed12a42c (diff) | |
| parent | 91f376692d472a5bf0c4b4033816250ec1ce3ab6 (diff) | |
| download | sqlalchemy-b330ffbc13ddb4274a004eab6a13ce40d641e555.tar.gz | |
Merge "Add future=True to create_engine/Session; unify select()"
Diffstat (limited to 'lib/sqlalchemy/sql/base.py')
| -rw-r--r-- | lib/sqlalchemy/sql/base.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 6cdab8eac..4bc6d8280 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -1388,3 +1388,25 @@ def _bind_or_error(schemaitem, msg=None): ) raise exc.UnboundExecutionError(msg) return bind + + +def _entity_namespace_key(entity, key): + """Return an entry from an entity_namespace. + + + Raises :class:`_exc.InvalidRequestError` rather than attribute error + on not found. + + """ + + ns = entity.entity_namespace + try: + return getattr(ns, key) + except AttributeError as err: + util.raise_( + exc.InvalidRequestError( + 'Entity namespace for "%s" has no property "%s"' + % (entity, key) + ), + replace_context=err, + ) |
