From cac7320eeb16e62f347dbf009a1b18edff7faa18 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 28 Dec 2013 16:37:54 -0500 Subject: - 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 --- lib/sqlalchemy/sql/elements.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'lib/sqlalchemy/sql') 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__() -- cgit v1.2.1