test that update()/insert() use the correct key when given InstrumentedAttributes.
(self, connection)
| 194 | assert_raises(sa.exc.ArgumentError, sa.orm.configure_mappers) |
| 195 | |
| 196 | def test_update_attr_keys(self, connection): |
| 197 | """test that update()/insert() use the correct key when given |
| 198 | InstrumentedAttributes.""" |
| 199 | |
| 200 | User, users = self.classes.User, self.tables.users |
| 201 | |
| 202 | self.mapper(User, users, properties={"foobar": users.c.name}) |
| 203 | |
| 204 | connection.execute(users.insert().values({User.foobar: "name1"})) |
| 205 | eq_( |
| 206 | connection.execute( |
| 207 | sa.select(User.foobar).where(User.foobar == "name1") |
| 208 | ).fetchall(), |
| 209 | [("name1",)], |
| 210 | ) |
| 211 | |
| 212 | connection.execute( |
| 213 | users.update().values({User.foobar: User.foobar + "foo"}) |
| 214 | ) |
| 215 | eq_( |
| 216 | connection.execute( |
| 217 | sa.select(User.foobar).where(User.foobar == "name1foo") |
| 218 | ).fetchall(), |
| 219 | [("name1foo",)], |
| 220 | ) |
| 221 | |
| 222 | def test_utils(self): |
| 223 | users = self.tables.users |