On Sep 30, 2010, at 4:47 PM, Dan wrote: > Hey, > > I am trying to create a funky relationship where I want to take a > field in a table, take a portion of it and then use that portion to > create a relation. Is this even possible? > > My relation is below > > reseller = relation(Reseller, > uselist = False, > primaryjoin = func.substring(credits.c.billing_code, 3, 25) == > Reseller.resellerid) > > Any suggestions to make this happen?
Put viewonly=True on the relation, specify the foreign_keys and remote_side arguments. Though dramatically simpler, just use a @property. Also, here's a very old example that uses _local_remote_pairs to do it: http://www.sqlalchemy.org/trac/attachment/ticket/610/cast_primaryjoin_example.py -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.