summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/compiler.py24
-rw-r--r--lib/sqlalchemy/sql/default_comparator.py5
2 files changed, 16 insertions, 13 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 5c7a29f99..f526203ac 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -1934,16 +1934,22 @@ class SQLCompiler(Compiled):
if not stmt._has_multi_parameters
else "%s_0" % c.key
)
- elif c.primary_key and implicit_returning:
- self.returning.append(c)
- value = self.process(value.self_group(), **kw)
- elif implicit_return_defaults and \
- c in implicit_return_defaults:
- self.returning.append(c)
- value = self.process(value.self_group(), **kw)
else:
- self.postfetch.append(c)
- value = self.process(value.self_group(), **kw)
+ if isinstance(value, elements.BindParameter) and \
+ value.type._isnull:
+ value = value._clone()
+ value.type = c.type
+
+ if c.primary_key and implicit_returning:
+ self.returning.append(c)
+ value = self.process(value.self_group(), **kw)
+ elif implicit_return_defaults and \
+ c in implicit_return_defaults:
+ self.returning.append(c)
+ value = self.process(value.self_group(), **kw)
+ else:
+ self.postfetch.append(c)
+ value = self.process(value.self_group(), **kw)
values.append((c, value))
elif self.isinsert:
diff --git a/lib/sqlalchemy/sql/default_comparator.py b/lib/sqlalchemy/sql/default_comparator.py
index c9125108a..7c803ac4c 100644
--- a/lib/sqlalchemy/sql/default_comparator.py
+++ b/lib/sqlalchemy/sql/default_comparator.py
@@ -261,10 +261,7 @@ class _DefaultColumnComparator(operators.ColumnOperators):
if isinstance(other, (ColumnElement, TextClause)):
if isinstance(other, BindParameter) and \
other.type._isnull:
- # TODO: perhaps we should not mutate the incoming
- # bindparam() here and instead make a copy of it.
- # this might be the only place that we're mutating
- # an incoming construct.
+ other = other._clone()
other.type = expr.type
return other
elif hasattr(other, '__clause_element__'):