A cycle between two rows, with a post_update on the many-to-one
(self)
| 894 | ) |
| 895 | |
| 896 | def test_post_update_m2o(self): |
| 897 | """A cycle between two rows, with a post_update on the many-to-one""" |
| 898 | |
| 899 | person, ball, Ball, Person = ( |
| 900 | self.tables.person, |
| 901 | self.tables.ball, |
| 902 | self.classes.Ball, |
| 903 | self.classes.Person, |
| 904 | ) |
| 905 | |
| 906 | self.mapper_registry.map_imperatively(Ball, ball) |
| 907 | self.mapper_registry.map_imperatively( |
| 908 | Person, |
| 909 | person, |
| 910 | properties=dict( |
| 911 | balls=relationship( |
| 912 | Ball, |
| 913 | primaryjoin=ball.c.person_id == person.c.id, |
| 914 | remote_side=ball.c.person_id, |
| 915 | post_update=False, |
| 916 | cascade="all, delete-orphan", |
| 917 | _legacy_inactive_history_style=( |
| 918 | self._legacy_inactive_history_style |
| 919 | ), |
| 920 | ), |
| 921 | favorite=relationship( |
| 922 | Ball, |
| 923 | primaryjoin=person.c.favorite_ball_id == ball.c.id, |
| 924 | post_update=True, |
| 925 | _legacy_inactive_history_style=( |
| 926 | self._legacy_inactive_history_style |
| 927 | ), |
| 928 | ), |
| 929 | ), |
| 930 | ) |
| 931 | |
| 932 | b = Ball(data="some data") |
| 933 | p = Person(data="some data") |
| 934 | p.balls.append(b) |
| 935 | p.balls.append(Ball(data="some data")) |
| 936 | p.balls.append(Ball(data="some data")) |
| 937 | p.balls.append(Ball(data="some data")) |
| 938 | p.favorite = b |
| 939 | sess = fixture_session() |
| 940 | sess.add(b) |
| 941 | sess.add(p) |
| 942 | |
| 943 | self.assert_sql_execution( |
| 944 | testing.db, |
| 945 | sess.flush, |
| 946 | RegexSQL("^INSERT INTO person", {"data": "some data"}), |
| 947 | Conditional( |
| 948 | testing.db.dialect.insert_executemany_returning, |
| 949 | [ |
| 950 | RegexSQL( |
| 951 | "^INSERT INTO ball", |
| 952 | lambda c: [ |
| 953 | {"person_id": p.id, "data": "some data"}, |
nothing calls this directly
no test coverage detected