I’d like to follow up on the Backref Arguments 
example from the documentation. 

First, to make sure I understand this correctly, are these two lines 
equivalent? I would assume so, considering this comment 
“By default, this value [primaryjoin] is computed based on the foreign key 
relationships of the parent and child tables (or association table).”

addresses = relationship("Address",

# Is like saying…

addresses = relationship("Address",

Now for the backref with an argument. In the example, the email’s local 
part `tony` is hardcoded. Is there a way to parameterize that local part 
elegantly (i.e. pass arguments to that relationship), or is the following 
function the recommended way to go:

def user_addresses(self, name):
    return [a for a in self.addresses if a.email.startswith(name)]


SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper


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.

Reply via email to