diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-12-18 12:22:12 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-12-18 21:50:14 -0500 |
commit | 27766512b2d037a8f0048dccc6e2f02c281fbc9a (patch) | |
tree | f6f721ee5c1b4da3e0c644b43ab4c8bcec4debfa /lib/sqlalchemy/sql/compiler.py | |
parent | 8294a336b1e6f23b5a7244e7aa457321fd3580bd (diff) | |
download | sqlalchemy-27766512b2d037a8f0048dccc6e2f02c281fbc9a.tar.gz |
Improve type detection for Values / Tuple
Fixed issue in new :class:`_sql.Values` construct where passing tuples of
objects would fall back to per-value type detection rather than making use
of the :class:`_schema.Column` objects passed directly to
:class:`_sql.Values` that tells SQLAlchemy what the expected type is. This
would lead to issues for objects such as enumerations and numpy strings
that are not actually necessary since the expected type is given.
note this changes NullType() to raise CompileError for
literal_processor; NullType() does not imply the actual value
NULL as much as it does "unknown type" so this should make failure
modes more clear.
Fixes: #5785
Change-Id: Ifbf5e78373102380b301098f30e15011efa98b5e
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 46f111d2c..a734bb582 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -2610,7 +2610,9 @@ class SQLCompiler(Compiled): v = "VALUES %s" % ", ".join( self.process( - elements.Tuple(*elem).self_group(), + elements.Tuple( + types=element._column_types, *elem + ).self_group(), literal_binds=element.literal_binds, ) for chunk in element._data |