summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/elements.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-12-28 16:37:54 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-12-28 16:37:54 -0500
commitcac7320eeb16e62f347dbf009a1b18edff7faa18 (patch)
treebece0cd0606d684b48be8c24237d6283955b62a6 /lib/sqlalchemy/sql/elements.py
parentd8bc6673c0bb34258bf4c54699ceede777664600 (diff)
downloadsqlalchemy-cac7320eeb16e62f347dbf009a1b18edff7faa18.tar.gz
- adjust the behavior of cast() to only provide a type for the bindparam()
if we are coercing straight from string. [ticket:2899] - rework the tests here to be individual
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r--lib/sqlalchemy/sql/elements.py10
1 files changed, 1 insertions, 9 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py
index dfebf09a8..56fca5dd8 100644
--- a/lib/sqlalchemy/sql/elements.py
+++ b/lib/sqlalchemy/sql/elements.py
@@ -1766,14 +1766,7 @@ class Cast(ColumnElement):
"""
self.type = type_api.to_instance(type_)
- self.clause = _literal_as_binds(expression, None)
- if isinstance(self.clause, BindParameter) and (
- self.clause.type._isnull
- or self.clause.type._type_affinity is self.type._type_affinity
- ):
- self.clause = self.clause._clone()
- self.clause.type = self.type
-
+ self.clause = _literal_as_binds(expression, type_=self.type)
self.typeclause = TypeClause(self.type)
def _copy_internals(self, clone=_clone, **kw):
@@ -2785,7 +2778,6 @@ def _only_column_elements(element, name):
"'%s'; got: '%s', type %s" % (name, element, type(element)))
return element
-
def _literal_as_binds(element, name=None, type_=None):
if hasattr(element, '__clause_element__'):
return element.__clause_element__()