diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2020-03-02 23:45:35 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-03-02 23:45:35 +0000 |
commit | b5050beb73b2e50b122c36e7dcdc06abffd472f2 (patch) | |
tree | 6679019ff418d6c346d5bd4cdc4aab4a73d9303e /lib/sqlalchemy/sql/compiler.py | |
parent | 2d052d43518a0f4d9751db7e699cfebd3724c1e5 (diff) | |
parent | 57dc36a01b2b334a996f73f6a78b3bfbe4d9f2ec (diff) | |
download | sqlalchemy-b5050beb73b2e50b122c36e7dcdc06abffd472f2.tar.gz |
Merge "Ensure all nested exception throws have a cause"
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 9c1f50ce1..d31cf67f8 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1074,7 +1074,7 @@ class SQLCompiler(Compiled): col = only_froms[element.element] else: col = with_cols[element.element] - except KeyError: + except KeyError as err: coercions._no_text_coercion( element.element, extra=( @@ -1082,6 +1082,7 @@ class SQLCompiler(Compiled): "GROUP BY / DISTINCT etc." ), exc_cls=exc.CompileError, + err=err, ) else: kwargs["render_label_as_label"] = col @@ -1671,8 +1672,11 @@ class SQLCompiler(Compiled): else: try: opstring = OPERATORS[operator_] - except KeyError: - raise exc.UnsupportedCompilationError(self, operator_) + except KeyError as err: + util.raise_( + exc.UnsupportedCompilationError(self, operator_), + replace_context=err, + ) else: return self._generate_generic_binary( binary, opstring, from_linter=from_linter, **kw @@ -3286,11 +3290,12 @@ class DDLCompiler(Compiled): if column.primary_key: first_pk = True except exc.CompileError as ce: - util.raise_from_cause( + util.raise_( exc.CompileError( util.u("(in table '%s', column '%s'): %s") % (table.description, column.name, ce.args[0]) - ) + ), + from_=ce, ) const = self.create_table_constraints( |