(self)
| 2775 | ) |
| 2776 | |
| 2777 | def test_compound_grouping(self): |
| 2778 | s = select(column("foo"), column("bar")).select_from(text("bat")) |
| 2779 | |
| 2780 | self.assert_compile( |
| 2781 | union(union(union(s, s), s), s), |
| 2782 | "((SELECT foo, bar FROM bat UNION SELECT foo, bar FROM bat) " |
| 2783 | "UNION SELECT foo, bar FROM bat) UNION SELECT foo, bar FROM bat", |
| 2784 | ) |
| 2785 | |
| 2786 | self.assert_compile( |
| 2787 | union(s, s, s, s), |
| 2788 | "SELECT foo, bar FROM bat UNION SELECT foo, bar " |
| 2789 | "FROM bat UNION SELECT foo, bar FROM bat " |
| 2790 | "UNION SELECT foo, bar FROM bat", |
| 2791 | ) |
| 2792 | |
| 2793 | self.assert_compile( |
| 2794 | union(s, union(s, union(s, s))), |
| 2795 | "SELECT foo, bar FROM bat UNION (SELECT foo, bar FROM bat " |
| 2796 | "UNION (SELECT foo, bar FROM bat " |
| 2797 | "UNION SELECT foo, bar FROM bat))", |
| 2798 | ) |
| 2799 | |
| 2800 | self.assert_compile( |
| 2801 | select(s.alias()), |
| 2802 | "SELECT anon_1.foo, anon_1.bar FROM " |
| 2803 | "(SELECT foo, bar FROM bat) AS anon_1", |
| 2804 | ) |
| 2805 | |
| 2806 | self.assert_compile( |
| 2807 | select(union(s, s).alias()), |
| 2808 | "SELECT anon_1.foo, anon_1.bar FROM " |
| 2809 | "(SELECT foo, bar FROM bat UNION " |
| 2810 | "SELECT foo, bar FROM bat) AS anon_1", |
| 2811 | ) |
| 2812 | |
| 2813 | self.assert_compile( |
| 2814 | select(except_(s, s).alias()), |
| 2815 | "SELECT anon_1.foo, anon_1.bar FROM " |
| 2816 | "(SELECT foo, bar FROM bat EXCEPT " |
| 2817 | "SELECT foo, bar FROM bat) AS anon_1", |
| 2818 | ) |
| 2819 | |
| 2820 | # this query sqlite specifically chokes on |
| 2821 | self.assert_compile( |
| 2822 | union(except_(s, s), s), |
| 2823 | "(SELECT foo, bar FROM bat EXCEPT SELECT foo, bar FROM bat) " |
| 2824 | "UNION SELECT foo, bar FROM bat", |
| 2825 | ) |
| 2826 | |
| 2827 | self.assert_compile( |
| 2828 | union(s, except_(s, s)), |
| 2829 | "SELECT foo, bar FROM bat " |
| 2830 | "UNION (SELECT foo, bar FROM bat EXCEPT SELECT foo, bar FROM bat)", |
| 2831 | ) |
| 2832 | |
| 2833 | # this solves it |
| 2834 | self.assert_compile( |
nothing calls this directly
no test coverage detected