Re: [sqlalchemy] How to define a column property for whether model is the latest of a one-to-many relationship

2018-11-07 Thread phil . nachum
Seems to work great. Thanks so much! On Wednesday, November 7, 2018 at 11:33:11 AM UTC-8, Mike Bayer wrote: > > On Wed, Nov 7, 2018 at 1:05 PM > > wrote: > > > > I need help with structuring the query too. I can implement a query with > raw SQL, but it involves subqueries, and I'm not sure

Re: [sqlalchemy] How to define a column property for whether model is the latest of a one-to-many relationship

2018-11-07 Thread phil . nachum
I need help with structuring the query too. I can implement a query with raw SQL, but it involves subqueries, and I'm not sure how to translate it to a column property (or if there's a better way which would avoid the need for a subquery entirely) On Wednesday, November 7, 2018 at 9:54:15 AM

[sqlalchemy] How to define a column property for whether model is the latest of a one-to-many relationship

2018-11-07 Thread phil . nachum
I have the following two models class Dataset(db.Model): __tablename__ = 'datasets' id = db.Column(db.Integer, primary_key=True) creation_datetime = db.Column(db.DateTime(timezone=False), nullable= False) sample_id = db.Column(db.Integer, db.ForeignKey('samples.id'), nullable=

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-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 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"

[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 =

[sqlalchemy] Loading model in a text fixture causes load options to be ignored

2018-07-03 Thread phil . nachum
Hello, I'm encountering an issue where loading a model in a text fixture causes the load options to be ignored when I load the same model in a Flask endpoint I have these two models class Plate(db.Model): container_id = db.Column(db.Integer, db.ForeignKey('containers.id')) container