On May 24, 2013, at 11:53 AM, YKdvd <davidobe...@gmail.com> wrote:

> 
> class Production(Base):
>       __table_args__ = {'schema':'Studio'}
>        id = Column('id', Integer, primary_key=True, nullable=False)
> 
> class Episode(Base):
>    ...
>   # some sort of relationship() back to Production, even though there is no 
> column to use as a foreign key
> 
> "Creating Custom Foreign Conditions" documents the remote() and foreign() 
> functions, and I was wondering if these could be used somehow.  I've played 
> around with something like
> 
>     production = relationship("Production", 
> primaryjoin=remote(Production.id)==foreign(???)) 
> 
> but I can't seem to find anything that works.  I can provide some sort of 
> instance method or property with the necessary id value for foreign(), but 
> I'm not sure if this is acceptable, or even if the remote reference is 
> correct (I've tried the string "Studio.productions.id" as well as the 
> Production.id variable.  

if I give you a row from the Episode table, and nothing else, tell me what row 
it refers to in Production, and how you know that.   

If the answer is, "nothing, only the code knows", then you can't use 
relationship(), just use a @property.   Though it's still possible that the 
rules that are in the code could be translated into SQL, but only if they 
ultimately derive from the data that's in that Episode row.

-- 
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 http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to