[Sqlalchemy-tickets] Issue #3969: negation of labeled element? (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Michael B. <iss...@bi...> - 2017-04-21 14:32:29
|
New issue 3969: negation of labeled element? https://bitbucket.org/zzzeek/sqlalchemy/issues/3969/negation-of-labeled-element Michael Bayer: this is technically something that semantically doesn't make sense, but in the "what I expect" category it does, which is to negate the inner element of a label. ``` #!python from sqlalchemy import * expr = or_(column('x') == 1, column('y') == 2) bug = not_(expr.label('foo')) from sqlalchemy.dialects import sqlite print bug.compile() print bug.compile(dialect=sqlite.dialect()) ``` ``` #! NOT x = :x_1 OR y = :y_1 x = ? OR y = ? = 0 ``` so the parenthesis are lost because we don't unwrap the label(), and we in fact hit a rule in ColumnElement._negate() where it assumes we're negating a true/false, so for a non-native-boolean it then sticks on "= 0" to the whole thing to make things worse. |