def test_where_empty(self): table1 = self.tables.mytable self.assert_compile( table1.update().where( BooleanClauseList._construct_raw(operators.and_)), "UPDATE mytable SET myid=:myid, name=:name, " "description=:description", ) self.assert_compile( table1.update().where( BooleanClauseList._construct_raw(operators.or_)), "UPDATE mytable SET myid=:myid, name=:name, " "description=:description", )
def replace(self, elem): if isinstance(elem, BinaryExpression): if elem.left in self.tscols or elem.right in self.tscols: return True_() return elem elif isinstance(elem, BooleanClauseList): clauses = [ self.replace(c) for c in elem.clauses if not isinstance(c, True_) ] assert len(clauses) if len(clauses) == 1: return clauses[0] elif elem.operator == operators.or_: return BooleanClauseList.or_(*clauses) elif elem.operator == operators.and_: return BooleanClauseList.and_(*clauses) raise RuntimeError(elem.operator) return elem