Does not apply to 0.6.9.
-sql
+ - Behavioral improvement: empty
+ conjunctions such as and_() and or_() will be
+ flattened in the context of an enclosing conjunction,
+ i.e. and_(x, or_()) will produce 'X' and not 'X AND
+ ()'. [ticket:2257].
+
- Fixed bug regarding calculation of "from" list
for a select() element. The "from" calc is now
delayed, so that if the construct uses a Column
s for s in
(c._compiler_dispatch(self, **kwargs)
for c in clauselist.clauses)
- if s is not None)
+ if s)
def visit_case(self, clause, **kwargs):
x = "CASE "
def _select_iterable(self):
return (self, )
+ def self_group(self, against=None):
+ if not self.clauses:
+ return self
+ else:
+ return super(BooleanClauseList, self).self_group(against=against)
+
class _Tuple(ClauseList, ColumnElement):
def __init__(self, *clauses, **kw):
checkparams = {'othername_1': 'asdf', 'othername_2':'foo', 'otherid_1': 9, 'myid_1': 12}
)
+ def test_nested_conjunctions_short_circuit(self):
+ """test that empty or_(), and_() conjunctions are collapsed by
+ an enclosing conjunction."""
+
+ t = table('t', column('x'))
+
+ self.assert_compile(
+ select([t]).where(and_(t.c.x==5,
+ or_(and_(or_(t.c.x==7))))),
+ "SELECT t.x FROM t WHERE t.x = :x_1 AND t.x = :x_2"
+ )
+ self.assert_compile(
+ select([t]).where(and_(or_(t.c.x==12,
+ and_(or_(t.c.x==8))))),
+ "SELECT t.x FROM t WHERE t.x = :x_1 OR t.x = :x_2"
+ )
+ self.assert_compile(
+ select([t]).where(and_(or_(or_(t.c.x==12),
+ and_(or_(), or_(and_(t.c.x==8)), and_())))),
+ "SELECT t.x FROM t WHERE t.x = :x_1 OR t.x = :x_2"
+ )
def test_distinct(self):
self.assert_compile(