Fixed issue in SQL math negation operator where the type of the
expression would no longer be the numeric type of the original.
This would cause issues where the type determined result set
behaviors.
Change-Id: If0e339614a3686e251235fc94b6f59310c4630a5
Fixes: #3735
.. changelog::
:version: 1.0.14
+ .. change::
+ :tags: bug, sql
+ :tickets: 3735
+
+ Fixed issue in SQL math negation operator where the type of the
+ expression would no longer be the numeric type of the original.
+ This would cause issues where the type determined result set
+ behaviors.
+
.. change::
:tags: bug, sql
:tickets: 3728
def _neg_impl(expr, op, **kw):
"""See :meth:`.ColumnOperators.__neg__`."""
- return UnaryExpression(expr, operator=operators.neg)
+ return UnaryExpression(expr, operator=operators.neg, type_=expr.type)
def _match_impl(expr, op, other, **kw):
"SELECT mytable.myid, mytable.name FROM "
"mytable WHERE mytable.myid != :myid_1 AND NOT mytable.name")
+ def test_negate_operator_type(self):
+ is_(
+ (-self.table1.c.myid).type,
+ self.table1.c.myid.type,
+ )
+
class LikeTest(fixtures.TestBase, testing.AssertsCompiledSQL):
__dialect__ = 'default'