test bidirectional post_update.
(self)
| 1005 | ) |
| 1006 | |
| 1007 | def test_post_update_backref(self): |
| 1008 | """test bidirectional post_update.""" |
| 1009 | |
| 1010 | person, ball, Ball, Person = ( |
| 1011 | self.tables.person, |
| 1012 | self.tables.ball, |
| 1013 | self.classes.Ball, |
| 1014 | self.classes.Person, |
| 1015 | ) |
| 1016 | |
| 1017 | self.mapper_registry.map_imperatively(Ball, ball) |
| 1018 | self.mapper_registry.map_imperatively( |
| 1019 | Person, |
| 1020 | person, |
| 1021 | properties=dict( |
| 1022 | balls=relationship( |
| 1023 | Ball, |
| 1024 | primaryjoin=ball.c.person_id == person.c.id, |
| 1025 | remote_side=ball.c.person_id, |
| 1026 | post_update=True, |
| 1027 | backref=backref( |
| 1028 | "person", |
| 1029 | post_update=True, |
| 1030 | _legacy_inactive_history_style=( |
| 1031 | self._legacy_inactive_history_style |
| 1032 | ), |
| 1033 | ), |
| 1034 | _legacy_inactive_history_style=( |
| 1035 | self._legacy_inactive_history_style |
| 1036 | ), |
| 1037 | ), |
| 1038 | favorite=relationship( |
| 1039 | Ball, |
| 1040 | primaryjoin=person.c.favorite_ball_id == ball.c.id, |
| 1041 | _legacy_inactive_history_style=( |
| 1042 | self._legacy_inactive_history_style |
| 1043 | ), |
| 1044 | ), |
| 1045 | ), |
| 1046 | ) |
| 1047 | |
| 1048 | sess = fixture_session() |
| 1049 | p1 = Person(data="p1") |
| 1050 | p2 = Person(data="p2") |
| 1051 | p3 = Person(data="p3") |
| 1052 | |
| 1053 | b1 = Ball(data="b1") |
| 1054 | |
| 1055 | b1.person = p1 |
| 1056 | sess.add_all([p1, p2, p3]) |
| 1057 | sess.commit() |
| 1058 | |
| 1059 | # switch here. the post_update |
| 1060 | # on ball.person can't get tripped up |
| 1061 | # by the fact that there's a "reverse" prop. |
| 1062 | b1.person = p2 |
| 1063 | sess.commit() |
| 1064 | eq_(p2, b1.person) |
nothing calls this directly
no test coverage detected