test a flat out name conflict.
(self, identical, clone_type)
| 495 | @testing.combinations(True, False, argnames="identical") |
| 496 | @testing.variation("clone_type", ["none", "clone", "annotated"]) |
| 497 | def test_conflicting_names(self, identical, clone_type): |
| 498 | """test a flat out name conflict.""" |
| 499 | |
| 500 | s1 = select(1) |
| 501 | c1 = s1.cte(name="cte1", recursive=True) |
| 502 | if clone_type.clone: |
| 503 | c2 = c1._clone() |
| 504 | if not identical: |
| 505 | c2 = c2.union(select(2)) |
| 506 | elif clone_type.annotated: |
| 507 | # this does not seem to trigger the issue that was fixed in |
| 508 | # #12364 however is still a worthy test |
| 509 | c2 = c1._annotate({"foo": "bar"}) |
| 510 | if not identical: |
| 511 | c2 = c2.union(select(2)) |
| 512 | else: |
| 513 | if identical: |
| 514 | s2 = select(1) |
| 515 | else: |
| 516 | s2 = select(column("q")) |
| 517 | c2 = s2.cte(name="cte1", recursive=True) |
| 518 | |
| 519 | s = select(c1, c2) |
| 520 | |
| 521 | if clone_type.clone and identical: |
| 522 | self.assert_compile( |
| 523 | s, |
| 524 | 'WITH RECURSIVE cte1("1") AS (SELECT 1) SELECT cte1.1, ' |
| 525 | 'cte1.1 AS "1_1" FROM cte1', |
| 526 | ) |
| 527 | elif clone_type.annotated and identical: |
| 528 | # annotated seems to have a slightly different rendering |
| 529 | # scheme here |
| 530 | self.assert_compile( |
| 531 | s, |
| 532 | 'WITH RECURSIVE cte1("1") AS (SELECT 1) SELECT cte1.1, ' |
| 533 | 'cte1.1 AS "1__1" FROM cte1', |
| 534 | ) |
| 535 | else: |
| 536 | assert_raises_message( |
| 537 | CompileError, |
| 538 | "Multiple, unrelated CTEs found with the same name: 'cte1'", |
| 539 | s.compile, |
| 540 | ) |
| 541 | |
| 542 | @testing.variation("annotated", [True, False]) |
| 543 | def test_cte_w_annotated(self, annotated): |
nothing calls this directly
no test coverage detected