Le jeudi 27 décembre 2007 13:29, Max Ischenko a écrit : > I'm migrating my Pylons app to SQLAlchemy 0.4 and get the following error: > > sqlalchemy.exceptions.ArgumentError: Error creating backref 'vacancies' on > relation 'JobPosting.jb_location (RefdataLocation)': property of that name > exists on mapper 'Mapper|RefdataLocation|ss_ref_location' > > Here is the offending code: > > mapper(JobPosting, jobad_posts_tbl, properties={ > 'jb_location' : relation(RefdataLocation, backref='vacancies'), > }) > mapper(RefdataLocation, location_tbl, properties={ > 'vacancies': relation(JobPosting, > order_by=desc(jobad_posts_tbl.c.published_date)) > }) > > What I am trying to achieve here is a that RefdataLocation().vacancies > could list all JobPosting()'s that belong to this location.
JobPosting's mapper tells RefdataLocation's mapper to add a property named 'vacancies', then you tell RefdataLocation's mapper to add a property named 'vacancies'. Replace these 2 "lines" by mapper( JobPosting, jobad_posts_tbl, properties = { 'jb_location': relation( RefdataLocation, backref = backref( 'vacancies', order_by = desc(jobad_posts_tbl.c.published_date) ) ), } ) and it should work as expected. -- Bertrand Croq ___________________________________________________________________ Net-ng Tel : +33 (0)223 21 21 53 14, rue Patis Tatelin Fax : +33 (0)223 21 21 60 Bâtiment G Web : http://www.net-ng.com 35000 RENNES e-mail: [EMAIL PROTECTED] FRANCE --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---