(self, a, b, connection)
| 902 | argnames="a, b", |
| 903 | ) |
| 904 | def test_a_in_b(self, a, b, connection): |
| 905 | q = self.tables.q |
| 906 | p = self.tables.p |
| 907 | |
| 908 | conn = connection |
| 909 | if a == "delete": |
| 910 | conn.execute(q.insert().values(y=10, z=1)) |
| 911 | cte = q.delete().where(q.c.z == 1).returning(q.c.z).cte("c") |
| 912 | expected = None |
| 913 | elif a == "insert": |
| 914 | cte = q.insert().values(z=1, y=10).returning(q.c.z).cte("c") |
| 915 | expected = (2, 10) |
| 916 | elif a == "update": |
| 917 | conn.execute(q.insert().values(x=5, y=10, z=1)) |
| 918 | cte = ( |
| 919 | q.update() |
| 920 | .where(q.c.z == 1) |
| 921 | .values(x=7) |
| 922 | .returning(q.c.z) |
| 923 | .cte("c") |
| 924 | ) |
| 925 | expected = (7, 5) |
| 926 | elif a == "select": |
| 927 | conn.execute(q.insert().values(x=5, y=10, z=1)) |
| 928 | cte = sa.select(q.c.z).cte("c") |
| 929 | expected = (5, 10) |
| 930 | |
| 931 | if b == "select": |
| 932 | conn.execute(p.insert().values(s=1)) |
| 933 | stmt = select(p.c.s, cte.c.z).where(p.c.s == cte.c.z) |
| 934 | elif b == "insert": |
| 935 | sel = select(1, cte.c.z) |
| 936 | stmt = ( |
| 937 | p.insert().from_select(["s", "t"], sel).returning(p.c.s, p.c.t) |
| 938 | ) |
| 939 | elif b == "delete": |
| 940 | stmt = p.insert().values(s=1, t=cte.c.z).returning(p.c.s, cte.c.z) |
| 941 | elif b == "update": |
| 942 | conn.execute(p.insert().values(s=1)) |
| 943 | stmt = ( |
| 944 | p.update() |
| 945 | .values(t=5) |
| 946 | .where(p.c.s == cte.c.z) |
| 947 | .returning(p.c.u, cte.c.z) |
| 948 | ) |
| 949 | eq_(list(conn.execute(stmt)), [(1, 1)]) |
| 950 | |
| 951 | eq_(conn.execute(select(q.c.x, q.c.y)).first(), expected) |
| 952 | |
| 953 | |
| 954 | class PKDefaultTest(fixtures.TestBase): |
nothing calls this directly
no test coverage detected