Re: [sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-27 Thread phil . nachum
Thanks for the detailed explanation. I'll try out some of those techniques. On Saturday, October 27, 2018 at 7:54:22 AM UTC-7, Mike Bayer wrote: > > On Fri, Oct 26, 2018 at 7:49 PM > > wrote: > > > > I see, thanks for the clarification about noload. > > > > Setting aside my specific issue,

Re: [sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-27 Thread Mike Bayer
On Fri, Oct 26, 2018 at 7:49 PM wrote: > > I see, thanks for the clarification about noload. > > Setting aside my specific issue, if using the session in > before_insert/before_update events is not a good idea, what is generally the > best way to perform validation across multiple models? Is it

Re: [sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-26 Thread phil . nachum
I see, thanks for the clarification about noload. Setting aside my specific issue, if using the session in before_insert/before_update events is not a good idea, what is generally the best way to perform validation across multiple models? Is it to just read the relationships from the model

Re: [sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-26 Thread Mike Bayer
also, your test seems to be making use of the "before_insert" and "before_update" events, inside which it's generally not a good idea to use the Session since you're in the middle of a flush, and also that event hook is before the SQL is emitted in any case, and addtionally the state of objects in

Re: [sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-26 Thread Mike Bayer
On Fri, Oct 26, 2018 at 6:03 PM wrote: > > That didn't fix it. > > Why should noload not be used? We use it quite often to have more granular > control over which tables get joined. Otherwise, some queries can become > unnecessarily slow attributes don't load unless you access them. if you

Re: [sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-26 Thread phil . nachum
That didn't fix it. Why should noload not be used? We use it quite often to have more granular control over which tables get joined. Otherwise, some queries can become unnecessarily slow On Friday, October 26, 2018 at 11:45:29 AM UTC-7, Mike Bayer wrote: > > please remove those "noload"

Re: [sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-26 Thread Mike Bayer
please remove those "noload" options, which really should never be used, and see if that fixes your problem On Fri, Oct 26, 2018 at 2:20 PM wrote: > > I have the following three models (with other columns omitted): > > > class ContainerSlot(db.Model): > __tablename__ = 'container_slots' > >

[sqlalchemy] How to validate consistent state across multiple models in a transaction?

2018-10-26 Thread phil . nachum
I have the following three models (with other columns omitted): class ContainerSlot(db.Model): __tablename__ = 'container_slots' id = db.Column(db.Integer, primary_key=True) tube_id = db.Column(db.Integer, db.ForeignKey('tubes.id'), unique=True, index=True) container_id =