def test_or_cond(self): cond_lh = BinaryOperator('billing.id', '=', 0) cond_rh = BinaryOperator('billing.cd', '!=', 101) cond_end = Or(cond_lh, cond_rh) (cond, params) = cond_end.glue() self.assertEqual( '"billing"."id" = %s OR "billing"."cd" != %s', cond ) self.assertEqual([0, 101], params)
def test_null_leaf(self): cond_and = And(NullLeaf(), Eq('a', 'b')) c, p = cond_and.glue() self.assertEqual('"a" = %s', c) self.assertEqual(['b'], p) cond_and = And(Eq('c', 'd'), NullLeaf()) c, p = cond_and.glue() self.assertEqual('"c" = %s', c) self.assertEqual(['d'], p) cond_and = And(NullLeaf(), NullLeaf()) c, p = cond_and.glue() self.assertEqual('', c) self.assertEqual([], p) cond_and = And(Eq('c', 'd'), NullLeaf()) cond_or = Or(Eq('e', 'f'), cond_and) c, p = cond_or.glue() self.assertEqual('"e" = %s OR "c" = %s', c) self.assertEqual(['f', 'd'], p)