MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_identity_key_3

Method test_identity_key_3

test/orm/test_utils.py:631–654  ·  view source on GitHub ↗

test a real Row works with identity_key. this was broken w/ 1.4 future mode as we are assuming a mapping here. to prevent regressions, identity_key now accepts any of dict, RowMapping, Row for the "row". found_during_type_annotation

(self, ormutil, rowtype)

Source from the content-addressed store, hash-verified

629 @_cases()
630 @testing.combinations("dict", "row", "mapping", argnames="rowtype")
631 def test_identity_key_3(self, ormutil, rowtype):
632 """test a real Row works with identity_key.
633
634 this was broken w/ 1.4 future mode as we are assuming a mapping
635 here. to prevent regressions, identity_key now accepts any of
636 dict, RowMapping, Row for the "row".
637
638 found_during_type_annotation
639
640
641 """
642 User, users = self.classes.User, self.tables.users
643
644 self.mapper_registry.map_imperatively(User, users)
645
646 if rowtype == "dict":
647 row = {users.c.id: 1, users.c.name: "Frank"}
648 elif rowtype in ("mapping", "row"):
649 row = result.result_tuple([users.c.id, users.c.name])((1, "Frank"))
650 if rowtype == "mapping":
651 row = row._mapping
652
653 key = ormutil.identity_key(User, row=row)
654 eq_(key, (User, (1,), None))
655
656 def test_identity_key_token(self):
657 User, users = self.classes.User, self.tables.users

Callers

nothing calls this directly

Calls 3

eq_Function · 0.90
map_imperativelyMethod · 0.80
identity_keyMethod · 0.45

Tested by

no test coverage detected