Re: [sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-05 Thread 'Tony Cosentini' via sqlalchemy
populate_existing doesn't change the behavior, but expunge_all does. The code works correctly now though - it's just our test setup/teardown that was causing trouble (although it does seem like weird behavior). Thanks again for so much help with such a great library, Tony On Thursday, January

Re: [sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-05 Thread Mike Bayer
not as much set-ordering as gc, most likely. add populate_existing to the query, that also should force the lazy loader to take effect On Thu, Jan 5, 2023, at 9:00 AM, Mike Bayer wrote: > the "b" object in question is not really "lazy loaded" in the usual sense > here because it's already

Re: [sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-05 Thread Mike Bayer
the "b" object in question is not really "lazy loaded" in the usual sense here because it's already present in the session, that looks like an unexpire query. the delete() might be just changing something where the issue comes down to a set-ordering issue, perhaps. try adding

[sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-04 Thread 'Tony Cosentini' via sqlalchemy
Ok, I was able to at least create a script that easily reproduces what I'm seeing - https://gist.github.com/tonycosentini/22f42455c5068898efa473760e4f65ed We have some code that runs before our tests to ensure all the tables are empty. When that runs, load_only doesn't seem to work. It sounds

[sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-04 Thread 'Tony Cosentini' via sqlalchemy
Funny enough, this is what I tried. I just wrote up a small sample script using defaultload + load_only and sure enough it works. There must be something in the code base I'm working with that prevents the load_only bit from being applied. I'm pretty sure defaultload is woroking fine. I'll

[sqlalchemy] Re: load_only when loading relatinoships from an instance

2023-01-04 Thread Michael Bayer
yeah you can use defaultload.load_only defaultload(ModelA.model_b).load_only(ModelB.only_field) On Wednesday, January 4, 2023 at 3:15:02 AM UTC-5 to...@revenuecat.com wrote: > Hi, > > This might be a strange question, but I tried to find this in the > documentation to no avail. > > Is it