Re: [sqlalchemy] How to combine statement eager loading with polymorphic relations

2023-09-14 Thread Mike Bayer
On Thu, Sep 14, 2023, at 7:36 AM, Cornelis Poppema wrote: > Hi all, > > I am new to sqlalchemy, I think the idea of what I am trying to achieve is > relatively simple, but I can't seem to figure out how to retrieve `.service` > in the same query. I failed to find an example in the 2.0

[sqlalchemy] How to combine statement eager loading with polymorphic relations

2023-09-14 Thread Cornelis Poppema
Hi all, I am struggling to combine a joinedload (or selectinload, whatever works) with the submodels of selectin_polymorphic. I have a model "step" that has a collections of "actions" that are relevant when my application reaches that step. These actions can be anything and also have their

Re: [sqlalchemy] sqlalchemy.orm.exc.FlushError on subclass

2023-09-14 Thread 'Luna Lucadou' via sqlalchemy
Thanks. We went with the helper class route, and it seems to be working much better than attempting to use inheritance in a manner that seems unsupported. On Wednesday, September 6, 2023 at 1:24:04 PM UTC-5 Mike Bayer wrote: > if you can't correct this model to apply the persistence details to

Re: [sqlalchemy] How to combine statement eager loading with polymorphic relations

2023-09-14 Thread Mike Bayer
working on that issue but you should also be able to do this right now: .options( selectinload(StepModel.actionbases.of_type(ServiceActionModel)).selectinload(ServiceActionModel.service), raiseload("*"), ) that produces more of a LEFT OUTER JOIN with a subquery situation but still