Monday, 2023-06-19

opendevreviewMerged openstack/oslo.middleware master: fix spelling  https://review.opendev.org/c/openstack/oslo.middleware/+/88624508:27
stephenfinzzzeek: This is not urgent, but if I've a small question on lazy-loading within the context of transaction_context_provider (i.e. context.session)16:18
stephenfinI'm calling the following within a decorated method16:18
stephenfin  context.session.get(Parent, some_id, options=(joinedload(Child.parent_id),))16:19
stephenfinIf I try to access parent.child within that method, it seems to load fine. If I do so outside the method, I get the "Parent instance foo is not bound to a Session" error message16:19
stephenfinIt shouldn't be lazy loading though, given the options. Am I misunderstanding something? Is there any way I can easily debug it?16:20
stephenfin(It's for Heat, btw, not that that matters too much)16:20
stephenfinI also tried the following to rule out lazy loading within the method, to no avail16:21
stephenfin  context.session.get(Parent, some_id, options=(joinedload(Child.parent_id), raiseload("*")))16:22
stephenfinOh, weird. If I switch to the following, things work as expected:16:31
stephenfin  context.session.get(Parent).filter_by(id=some_id).options(joinedload(Child.parent_id),).first()16:32
stephenfinSorry, s/get/query/16:32
stephenfin  context.session.query(Parent).filter_by(id=some_id).options(joinedload(Child.parent_id),).first()16:32
stephenfinUgh. looks like I should be setting populate_existing=True Easily Googled once I realised there was a difference https://stackoverflow.com/a/69602929/61342816:35

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!