Background:

I have a two model classes where one is a parent of the other via a one to 
many relationship. The parent has a collection of the children with a 
backref:


class Parent(base):
  __tablename__ = "parent_table"


  parent_key = Column(String, primary_key=True)
  some_quantity = Column(Integer)

  children = relationship("Parent", backref="parent_table")


class Child(base):
  __tablename__ = "child_table"


  child_key = Column(String, primary_key=True)
  some_quantity = Column(Integer)
  parent_key = Column(String, ForeignKey("parent_table.parent_key"))



I'm running into the following problem:

When I add a child to the parent collection, I have to make sure that the 
sum of the

some_quantitiy

fields of all children on the same parent do not exceed the

some_quantity

field of the parent. I tried adding a validator like so:


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to