Post_update only fires off when needed. This test case used to produce many superfluous update statements, particularly upon delete
(self)
| 1285 | self.path = path |
| 1286 | |
| 1287 | def test_one(self): |
| 1288 | """Post_update only fires off when needed. |
| 1289 | |
| 1290 | This test case used to produce many superfluous update statements, |
| 1291 | particularly upon delete |
| 1292 | |
| 1293 | """ |
| 1294 | |
| 1295 | node, Node = self.tables.node, self.classes.Node |
| 1296 | |
| 1297 | self.mapper_registry.map_imperatively( |
| 1298 | Node, |
| 1299 | node, |
| 1300 | properties={ |
| 1301 | "children": relationship( |
| 1302 | Node, |
| 1303 | primaryjoin=node.c.id == node.c.parent_id, |
| 1304 | cascade="all", |
| 1305 | backref=backref("parent", remote_side=node.c.id), |
| 1306 | ), |
| 1307 | "prev_sibling": relationship( |
| 1308 | Node, |
| 1309 | primaryjoin=node.c.prev_sibling_id == node.c.id, |
| 1310 | remote_side=node.c.id, |
| 1311 | uselist=False, |
| 1312 | ), |
| 1313 | "next_sibling": relationship( |
| 1314 | Node, |
| 1315 | primaryjoin=node.c.next_sibling_id == node.c.id, |
| 1316 | remote_side=node.c.id, |
| 1317 | uselist=False, |
| 1318 | post_update=True, |
| 1319 | ), |
| 1320 | }, |
| 1321 | ) |
| 1322 | |
| 1323 | session = fixture_session(autoflush=False) |
| 1324 | |
| 1325 | def append_child(parent, child): |
| 1326 | if parent.children: |
| 1327 | parent.children[-1].next_sibling = child |
| 1328 | child.prev_sibling = parent.children[-1] |
| 1329 | parent.children.append(child) |
| 1330 | |
| 1331 | def remove_child(parent, child): |
| 1332 | child.parent = None |
| 1333 | node = child.next_sibling |
| 1334 | node.prev_sibling = child.prev_sibling |
| 1335 | child.prev_sibling.next_sibling = node |
| 1336 | session.delete(child) |
| 1337 | |
| 1338 | root = Node("root") |
| 1339 | |
| 1340 | about = Node("about") |
| 1341 | cats = Node("cats") |
| 1342 | stories = Node("stories") |
| 1343 | bruce = Node("bruce") |
| 1344 |
nothing calls this directly
no test coverage detected