diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2021-11-05 20:34:39 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2021-11-05 20:34:39 +0000 |
commit | 5b1c9053b0903b2d5a06f82b47fe16a870696ddc (patch) | |
tree | bc95546ab5a185952e7ff336de2ff875bb222930 /lib/sqlalchemy/sql/compiler.py | |
parent | 5501649d1a78ae0a2f570cd54d2be6289a28ce2d (diff) | |
parent | 0c44a1e77cfde0f841a4a64140314c6b833efdab (diff) | |
download | sqlalchemy-5b1c9053b0903b2d5a06f82b47fe16a870696ddc.tar.gz |
Merge "use tuple expansion if type._is_tuple, test for Sequence if no type" into main
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index bcede5d76..96349578c 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -2024,8 +2024,14 @@ class SQLCompiler(Compiled): [parameter.type], parameter.expand_op ) - elif isinstance(values[0], (tuple, list)): - assert typ_dialect_impl._is_tuple_type + elif typ_dialect_impl._is_tuple_type or ( + typ_dialect_impl._isnull + and isinstance(values[0], util.collections_abc.Sequence) + and not isinstance( + values[0], util.string_types + util.binary_types + ) + ): + replacement_expression = ( "VALUES " if self.dialect.tuple_in_values else "" ) + ", ".join( @@ -2041,7 +2047,6 @@ class SQLCompiler(Compiled): for i, tuple_element in enumerate(values) ) else: - assert not typ_dialect_impl._is_tuple_type replacement_expression = ", ".join( self.render_literal_value(value, parameter.type) for value in values @@ -2070,10 +2075,14 @@ class SQLCompiler(Compiled): [parameter.type], parameter.expand_op ) - elif ( - isinstance(values[0], (tuple, list)) - and not typ_dialect_impl._is_array + elif typ_dialect_impl._is_tuple_type or ( + typ_dialect_impl._isnull + and isinstance(values[0], util.collections_abc.Sequence) + and not isinstance( + values[0], util.string_types + util.binary_types + ) ): + assert not typ_dialect_impl._is_array to_update = [ ("%s_%s_%s" % (name, i, j), value) for i, tuple_element in enumerate(values, 1) |