| 96 | ) |
| 97 | |
| 98 | def test_plain_select(self, connection): |
| 99 | a = self.tables.a |
| 100 | |
| 101 | cs = connection.scalars |
| 102 | |
| 103 | for _ in range(3): |
| 104 | x1 = random.randint(1, 10) |
| 105 | |
| 106 | eq_(cs(select(a).where(a.c.data == x1)).all(), [x1]) |
| 107 | stmt = select(a).where(a.c.data == bindparam("x", x1)) |
| 108 | eq_(cs(stmt).all(), [x1]) |
| 109 | |
| 110 | x1 = random.randint(1, 10) |
| 111 | eq_(cs(stmt.params({"x": x1})).all(), [x1]) |
| 112 | |
| 113 | x1 = random.randint(1, 10) |
| 114 | eq_(cs(stmt, {"x": x1}).all(), [x1]) |
| 115 | |
| 116 | x1 = random.randint(1, 10) |
| 117 | x2 = random.randint(1, 10) |
| 118 | eq_(cs(stmt.params({"x": x1}), {"x": x2}).all(), [x2]) |
| 119 | |
| 120 | stmt2 = stmt.params(x=6).subquery().select() |
| 121 | eq_(cs(stmt2).all(), [6]) |
| 122 | eq_(cs(stmt2.params({"x": 2})).all(), [2]) |
| 123 | |
| 124 | with expect_deprecated( |
| 125 | r"The params\(\) and unique_params\(\) " |
| 126 | "methods on non-statement" |
| 127 | ): |
| 128 | # NOTE: can't mix and match the two params styles here |
| 129 | stmt3 = stmt.params(x=6).subquery().params(x=8).select() |
| 130 | eq_(cs(stmt3).all(), [6]) |
| 131 | eq_(cs(stmt3.params({"x": 9})).all(), [9]) |
| 132 | |
| 133 | def test_union(self, connection): |
| 134 | a = self.tables.a |