- attached test.py
mysql (nonrendered) cast loses operator precedence
I ran into an issue with cast and mysql. The basic idea is:
inner_expression that evaluates to a simple add: 4 + 2 cast(inner_expression as Float) / 2
If mysql decides it doesn't need the cast for whatever reason, inner_expression is not grouped, which messes with the operator precedence, so the rendered sql looks like: 4 + 2 / 2 instead of (4 + 2) / 2.
Using sqlalchemy 0.7.6 with mysql 5.1.
I worked around this issue by just casting the first item in inner_expression to float instead of the whole expression. I also was able to work around it by calling self_group() on inner_expression.
Comments (3)
-
reporter -
repo owner thanks, I think fdda4b0e018f8c1a869411b7ed31387ea90cb082 should fix this nicely as the expression can tell us whether or not it wants to be grouped.
-
repo owner - removed milestone
Removing milestone: 0.7.7 (automated comment)
- Log in to comment
Simple unittest showing sqlite vs mysql