Hi, I want to represent a One to Many relationship with an additional default value that depends on a value in the foreign table.
I think what I want is something like the following: class UserDatabase(Base): db_id = Column(Integer, primary_key=True) repo_id = Column(Integer, ForeignKey("UserDatabase.db_id"), nullable=True) name = Column(String(128)) description = Column(Text) conn_host = Column(String(128)) conn_port = Column(Integer) schemas = relationship("UserDatabaseSchema", lazy="dynamic") # Where is_default_schema == True default_schema = relationship("UserDatabaseSchema", primaryjoin=???, lazy="dynamic") class UserDatabaseSchema(Base): schema_id = Column(Integer, primary_key=True) db_id = Column(Integer, ForeignKey("UserDatabase.db_id")) name = Column(String(128)) description = Column(Text) is_default_schema = Column(Boolean) but I'm not sure if primaryjoin is the proper argument for relationship and, if it is, what the expression should be. Or is this something that's best handled a different way? Thanks, Brian -- 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 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.