I have a subscriber and address table. a subscriber will have one and only one 'MAIN' address. I want the subscriber and MAIN address to be represented by one class 'Subscriber'. However, I want that class to have a collection 'addresses' which contains other addresses (e.g. old addresses) - (it can include the 'MAIN' address too .. or not.. I don't care)
subscriber_table = Table('subscriber', metadata, Column('id', primary_key=True), autoload=True) address_table = Table('address', metadata, Column('subscriber_id', ForeignKey ('subscriber.id'), primary_key=True), Column('address_type', primary_key=True), autoload=True) subscriber_with_default_address = sql.join( subscriber_table.c.id == address_table.c.subscriber_id).??? <- something to say address_table.type is 'MAIN' mapper(Address, address_table) mapper(Subscriber, subscriber_and_address, properties={ 'id':[subscriber_table.c.id, address_table.c.subscriber_id], 'addresses' : relation(Address, collection_class=Addresses, backref='customer') }) a) I can't quite figure out how to say (address.type is default) b) even without this I get: sqlalchemy.exc.ArgumentError: Can't determine relation direction for relationshi p 'Subscriber.addresses' - foreign key columns are present in both the parent an d the child's mapped tables. Specify 'foreign_keys' argument. if I do specify foreign_keys parameter to the relation function, then I still get the same. Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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 -~----------~----~----~----~------~----~------~--~---