Does anyone know if there is an easy way to extend the relationships system
so that I can specify the uselist I expect for back_populates relationships?
One of my projects has a complex model with a mix of one-to-one and
one-to-many relationships that declare `uselist`. I'd like to ensure I
declare the correct `uselist` on each side of the relationship, and ensure
an Exception is raised at runtime if one side is declared incorrectly.
as a use-case example, I'd like to do something like:
class Foo(Base):
id = Column(Integer, primary_key=True)
bars = relationship("Bar",
primaryjoin="Foo.id==Bar.foo_id",
uselist=True,
back_populates="foo",
back_populates_uselist=False, # ensure the
`uselist` on the `back_populates` relationship is False
)
class Bar(Base):
id = Column(Integer, primary_key=True)
foo_id = Column(Integer)
foo = relationship("Foo",
primaryjoin="Bar.foo_id==Foo.id",
uselist=False,
back_populates="bars",
back_populates_uselist=True, # ensure the `uselist`
on the `back_populates` relationship is True
)
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/07adaa47-0556-485d-be89-a102e8bbd2d5%40googlegroups.com.