| 492 | @testing.combinations(True, False, argnames="reverse") |
| 493 | @testing.combinations(True, False, argnames="negate") |
| 494 | def test_associatives(self, op, reverse, negate): |
| 495 | t1 = table("t", column("q"), column("p")) |
| 496 | |
| 497 | num = 500 |
| 498 | |
| 499 | expr = op(t1.c.q, t1.c.p) |
| 500 | |
| 501 | if reverse: |
| 502 | for i in range(num - 1, -1, -1): |
| 503 | expr = op(column(f"d{i}"), expr) |
| 504 | else: |
| 505 | for i in range(num): |
| 506 | expr = op(expr, column(f"d{i}")) |
| 507 | |
| 508 | opstring = compiler.OPERATORS[op] |
| 509 | exprs = opstring.join(f"d{i}" for i in range(num)) |
| 510 | |
| 511 | if negate: |
| 512 | self.assert_compile( |
| 513 | select(~expr), |
| 514 | ( |
| 515 | f"SELECT NOT (t.q{opstring}t.p{opstring}{exprs}) " |
| 516 | "AS anon_1 FROM t" |
| 517 | if not reverse |
| 518 | else ( |
| 519 | f"SELECT NOT ({exprs}{opstring}t.q{opstring}t.p) " |
| 520 | "AS anon_1 FROM t" |
| 521 | ) |
| 522 | ), |
| 523 | ) |
| 524 | else: |
| 525 | self.assert_compile( |
| 526 | select(expr), |
| 527 | ( |
| 528 | f"SELECT t.q{opstring}t.p{opstring}{exprs} " |
| 529 | "AS anon_1 FROM t" |
| 530 | if not reverse |
| 531 | else ( |
| 532 | f"SELECT {exprs}{opstring}t.q{opstring}t.p " |
| 533 | "AS anon_1 FROM t" |
| 534 | ) |
| 535 | ), |
| 536 | ) |
| 537 | |
| 538 | @testing.combinations( |
| 539 | operators.gt, |