From ebb4b02c2136b3a71989867a52665e34bdfd4236 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 30 Nov 2007 21:25:42 +0000 Subject: [PATCH] added test to ensure two conflicting m2m + backrefs raise an error --- test/orm/manytomany.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/orm/manytomany.py b/test/orm/manytomany.py index 8b310f86c5..5608ae67de 100644 --- a/test/orm/manytomany.py +++ b/test/orm/manytomany.py @@ -2,7 +2,7 @@ import testbase from sqlalchemy import * from sqlalchemy.orm import * from testlib import * - +from sqlalchemy import exceptions class Place(object): '''represents a place''' @@ -68,6 +68,19 @@ class M2MTest(ORMTest): Column('pl2_id', Integer, ForeignKey('place.place_id')), ) + def testerror(self): + mapper(Place, place, properties={ + 'transitions':relation(Transition, secondary=place_input, backref='places') + }) + mapper(Transition, transition, properties={ + 'places':relation(Place, secondary=place_input, backref='transitions') + }) + try: + compile_mappers() + assert False + except exceptions.ArgumentError, e: + assert str(e) == "Error creating backref 'transitions' on relation 'Transition.places (Place)': property of that name exists on mapper 'Mapper|Place|place'" + def testcircular(self): """tests a many-to-many relationship from a table to itself.""" -- 2.47.3