| 806 | assert set(clause2._bindparams.keys()) == {"bar", "lala"} |
| 807 | |
| 808 | def test_select(self): |
| 809 | s2 = select(t1) |
| 810 | s2_assert = str(s2) |
| 811 | s3_assert = str(select(t1).where(t1.c.col2 == 7)) |
| 812 | |
| 813 | class Vis(CloningVisitor): |
| 814 | def visit_select(self, select): |
| 815 | select.where.non_generative(select, t1.c.col2 == 7) |
| 816 | |
| 817 | s3 = Vis().traverse(s2) |
| 818 | assert str(s3) == s3_assert |
| 819 | assert str(s2) == s2_assert |
| 820 | print(str(s2)) |
| 821 | print(str(s3)) |
| 822 | |
| 823 | class Vis(ClauseVisitor): |
| 824 | def visit_select(self, select): |
| 825 | select.where.non_generative(select, t1.c.col2 == 7) |
| 826 | |
| 827 | Vis().traverse(s2) |
| 828 | assert str(s2) == s3_assert |
| 829 | |
| 830 | s4_assert = str(select(t1).where(and_(t1.c.col2 == 7, t1.c.col3 == 9))) |
| 831 | |
| 832 | class Vis(CloningVisitor): |
| 833 | def visit_select(self, select): |
| 834 | select.where.non_generative(select, t1.c.col3 == 9) |
| 835 | |
| 836 | s4 = Vis().traverse(s3) |
| 837 | print(str(s3)) |
| 838 | print(str(s4)) |
| 839 | assert str(s4) == s4_assert |
| 840 | assert str(s3) == s3_assert |
| 841 | |
| 842 | s5_assert = str(select(t1).where(and_(t1.c.col2 == 7, t1.c.col1 == 9))) |
| 843 | |
| 844 | class Vis(CloningVisitor): |
| 845 | def visit_binary(self, binary): |
| 846 | if binary.left is t1.c.col3: |
| 847 | binary.left = t1.c.col1 |
| 848 | binary.right = bindparam("col1", unique=True) |
| 849 | |
| 850 | s5 = Vis().traverse(s4) |
| 851 | print(str(s4)) |
| 852 | print(str(s5)) |
| 853 | assert str(s5) == s5_assert |
| 854 | assert str(s4) == s4_assert |
| 855 | |
| 856 | def test_union(self): |
| 857 | u = union(t1.select(), t2.select()) |