summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-12-18 12:22:12 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-12-18 21:50:14 -0500
commit27766512b2d037a8f0048dccc6e2f02c281fbc9a (patch)
treef6f721ee5c1b4da3e0c644b43ab4c8bcec4debfa /lib/sqlalchemy/sql/compiler.py
parent8294a336b1e6f23b5a7244e7aa457321fd3580bd (diff)
downloadsqlalchemy-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.py4
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