It looks there is a problem in the many-to-many mapping. Using the classic 'students enrol in many courses and a course is taken by many students' as an example:

studentTbl = Table('student', engine,
                   Column('id', Integer, primary_key=True),
                   Column('name', String))

courseTbl = Table('course', engine,
                   Column('id', Integer, primary_key=True),
                   Column('name', String))

enrolTbl = Table('enrol', engine,
                   Column('student_id', Integer,
                           ForeignKey('student.id'),
                           primary_key=True),
                   Column('course_id', Integer,
                           ForeignKey('course.id'),
                           primary_key=True))

class Student(object):
    pass


class Course(object):
    pass

Student.mapper = mapper(Student, studentTbl)
Course.mapper = mapper(Course, courseTbl)

Student.mapper.add_property('courses',
        relation(Course.mapper, enrolTbl, lazy=False))

Course.mapper.add_property('students',
        relation(Student.mapper, enrolTbl, lazy=False))

studentTbl.create()
courseTbl.create()
enrolTbl.create()

s1 = Student()
s1.id = 1
s1.name = 'Student1'

c1 = Course()
c1.id = 1
c1.name='Course1'

s1.courses.append(c1)

objectstore.commit()

s = Student.mapper.select()

I get an error:
"Circular eager load relationship detected on Mapper|Student|student courses{'courses': <sqlalchemy.mapping.properties.EagerLoader object at 0xb72a50cc>, 'id': <sqlalchemy.mapping.properties.ColumnProperty object at 0xb72a516c>, 'name': <sqlalchemy.mapping.properties.ColumnProperty object at 0xb72a51ac>}: None"

Am I missing something?

Note that this is using the latest svn with postgres as the db, in a previous version the error was thrown when the objectstore.commit() was executed, now it is in the select().

Robert



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to