to retrieve views marked as "SYSTEM VIEW".
courtesy Matthew Turland.
+ - [bug] Fixed bug whereby if cast() is used
+ on a SQL expression whose type is not supported
+ by cast() and therefore CAST isn't rendered by
+ the dialect, the order of evaluation could change
+ if the casted expression required that it be
+ grouped; grouping is now applied to those
+ expressions. [ticket:2467]
+
0.7.6
=====
- orm
def visit_cast(self, cast, **kwargs):
# No cast until 4, no decimals until 5.
if not self.dialect._supports_cast:
- return self.process(cast.clause)
+ return self.process(cast.clause.self_group())
type_ = self.process(cast.typeclause)
if type_ is None:
- return self.process(cast.clause)
+ return self.process(cast.clause.self_group())
return 'CAST(%s AS %s)' % (self.process(cast.clause), type_)
dialect=dialect
)
+ def test_cast_grouped_expression_non_castable(self):
+ self.assert_compile(
+ cast(sql.column('x') + sql.column('y'), Float),
+ "(x + y)"
+ )
+
+ def test_cast_grouped_expression_pre_4(self):
+ dialect = mysql.dialect()
+ dialect.server_version_info = (3, 2, 3)
+ self.assert_compile(
+ cast(sql.column('x') + sql.column('y'), Integer),
+ "(x + y)",
+ dialect=dialect
+ )
+
def test_extract(self):
t = sql.table('t', sql.column('col1'))