Hey Robert -

I checked in a tiny patch to alleviate the recursive problem with the particular test case you have below, and added the test to test/ manytomany.py as M2MTest2.testcircular. so now the test passes completely.

changeset: http://www.sqlalchemy.org/trac/changeset/713

So while I dont see any further symptoms, i didnt look too hard beyond the test you just gave me....so see if you can continue on with your testing.

On Dec 14, 2005, at 7:47 PM, Robert Leftwich wrote:

Michael Bayer wrote:
hey folks -
I just checked in the "backref" feature.

There is a recursion problem when deleting items out of a m:n mapped relationship:

studentTbl = Table('student', engine, Column ('name', String, primary_key=True)) courseTbl = Table('course', engine, Column ('name', String, primary_key=True))
enrolTbl = Table('enrol', engine,
Column('student_id', String, ForeignKey ('student.name'), primary_key=True), Column('course_id', String, ForeignKey ('course.name'), primary_key=True))
class Student(object):
        def __init__(self, name=''):
        self.name = name
        class Course(object):
        def __init__(self, name=''):
        self.name = name
Student.mapper = mapper(Student, studentTbl)
Course.mapper = mapper(Course, courseTbl, properties = {'students': relation(Student.mapper, enrolTbl, lazy=True, backref='courses')})
studentTbl.create()
courseTbl.create()
enrolTbl.create()
s1 = Student('Student1')
c1 = Course('Course1')
c2 = Course('Course2')
c3 = Course('Course3')
s1.courses.append(c1)
s1.courses.append(c2)
c1.students.append(s1)
c3.students.append(s1)
assert len(s1.courses) == 3
assert len(c1.students) == 1
objectstore.commit()
objectstore.clear()
s = Student.mapper.get_by(name='Student1')
c = Course.mapper.get_by(name='Course3')
assert len(s.courses) == 3
del s.courses[1]
assert len(s.courses) == 2
... RuntimeError: maximum recursion depth exceeded...


Also, there are some instances when I delete an item that I'm getting the following error:

IndexError: list assignment index out of range
Traceback:
  ....
File "/home/robert/tools/python/sqlalchemy/lib/sqlalchemy/ util.py", line 259, in __delitem__
    del self.data[i]

but I haven't been able to distil it down to a small test case as yet - it always triggers the recursion problem.

Lastly, if I use remove() instead of del in the first test, i.e.

assert len(s.courses) == 3
s.courses.remove(c2)
assert len(s.courses) == 2

There is no recursion error, but the last assertion fails, i.e. the remove() hasn't actually removed c2.

Hopefully, these problems are all related (excuse the pun:-))

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



-------------------------------------------------------
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