opendevreview | Merged openstack/oslo.middleware master: fix spelling https://review.opendev.org/c/openstack/oslo.middleware/+/886245 | 08:27 |
---|---|---|
stephenfin | zzzeek: 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 |
stephenfin | I'm calling the following within a decorated method | 16:18 |
stephenfin | context.session.get(Parent, some_id, options=(joinedload(Child.parent_id),)) | 16:19 |
stephenfin | If 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 message | 16:19 |
stephenfin | It 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 |
stephenfin | I also tried the following to rule out lazy loading within the method, to no avail | 16:21 |
stephenfin | context.session.get(Parent, some_id, options=(joinedload(Child.parent_id), raiseload("*"))) | 16:22 |
stephenfin | Oh, 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 |
stephenfin | Sorry, s/get/query/ | 16:32 |
stephenfin | context.session.query(Parent).filter_by(id=some_id).options(joinedload(Child.parent_id),).first() | 16:32 |
stephenfin | Ugh. looks like I should be setting populate_existing=True Easily Googled once I realised there was a difference https://stackoverflow.com/a/69602929/613428 | 16:35 |
Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!