[sqlalchemy] Re: many-to-many relation, 'secondaryjoin' is needed as well
Oh I did it 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 -~--~~~~--~~--~--~---
[sqlalchemy] many-to-many relation, 'secondaryjoin' is needed as well
Hello. I'v get this error while add new record to Service table. many-to-many relation, 'secondaryjoin' is needed as well. % (self)) sqlalchemy.exc.ArgumentError: Could not determine join condition between parent/child tables on relation Service.services. Specify a 'primaryjoin' expression. If this is a many-to-many relation, 'secondaryjoin' is needed as well. services_table = Table('service', metadata, Column('id', types.Integer, primary_key=True, autoincrement=True), Column('table', types.Unicode(10)), # a or b Column('name', types.Unicode(255), nullable=False), Column('code', types.Integer), ) service_btype_table = Table('service_btype', metadata, Column('service_b_id', types.Integer, ForeignKey('service.id'), primary_key=True), Column('service_a_id', types.Integer, ForeignKey('service.id'), primary_key=True) ) mapper(Service, services_table, properties={'services': relation(Service, backref='services', secondary=service_btype_table)}) Whats wrong in code? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: many-to-many relation, 'secondaryjoin' is needed as well
1. the backref is invalid. you're attempting to create a relation called services twice on the same class. 2. the relation is self-referential - it can't be automatically determined which join to apply for Service-service_type_table and service_type_table-Service - you need to use both primaryjoin and secondaryjoin to define this. examples are athttp://www.sqlalchemy.org/docs/05/mappers.html#specifying-alternate-j... . In example there are two classes class User(object): pass class Address(object): pass but I have only one It it possible to make join like Service 2 marked table B can contain Service 1, 3 marked table A in the same table [service] id table name code 1Aservice1 9843904 2Bserivce2 4394343 3Aservice3 6632901 [service_btype] service_b_idservice_a_id 2 1 2 3 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---