MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_update_attr_keys

Method test_update_attr_keys

test/orm/test_mapper.py:196–220  ·  view source on GitHub ↗

test that update()/insert() use the correct key when given InstrumentedAttributes.

(self, connection)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

eq_Function · 0.90
mapperMethod · 0.45
executeMethod · 0.45
valuesMethod · 0.45
insertMethod · 0.45
fetchallMethod · 0.45
whereMethod · 0.45
selectMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected