| 476 | @testing.combinations(True, False, argnames="reverse") |
| 477 | @testing.combinations(True, False, argnames="negate") |
| 478 | def test_associatives(self, op, reverse, negate): |
| 479 | t1 = table("t", column("q"), column("p")) |
| 480 | |
| 481 | num = 500 |
| 482 | |
| 483 | expr = op(t1.c.q, t1.c.p) |
| 484 | |
| 485 | if reverse: |
| 486 | for i in range(num - 1, -1, -1): |
| 487 | expr = op(column(f"d{i}"), expr) |
| 488 | else: |
| 489 | for i in range(num): |
| 490 | expr = op(expr, column(f"d{i}")) |
| 491 | |
| 492 | opstring = compiler.OPERATORS[op] |
| 493 | exprs = opstring.join(f"d{i}" for i in range(num)) |
| 494 | |
| 495 | if negate: |
| 496 | self.assert_compile( |
| 497 | select(~expr), |
| 498 | ( |
| 499 | f"SELECT NOT (t.q{opstring}t.p{opstring}{exprs}) " |
| 500 | "AS anon_1 FROM t" |
| 501 | if not reverse |
| 502 | else f"SELECT NOT ({exprs}{opstring}t.q{opstring}t.p) " |
| 503 | "AS anon_1 FROM t" |
| 504 | ), |
| 505 | ) |
| 506 | else: |
| 507 | self.assert_compile( |
| 508 | select(expr), |
| 509 | ( |
| 510 | f"SELECT t.q{opstring}t.p{opstring}{exprs} " |
| 511 | "AS anon_1 FROM t" |
| 512 | if not reverse |
| 513 | else f"SELECT {exprs}{opstring}t.q{opstring}t.p " |
| 514 | "AS anon_1 FROM t" |
| 515 | ), |
| 516 | ) |
| 517 | |
| 518 | @testing.combinations( |
| 519 | operators.gt, |