- changed status to resolved
add a "holding zone" for backref-appended collection items when collection hasn't lazy loaded
Issue #871
resolved
i.e.
mapper(Student, table_students, properties={
'marks': relation(Mark, cascade='all, delete-orphan',
backref='student')
})
mapper(Subject, table_subjects, properties={
'marks': relation(Mark, cascade='all, delete-orphan',
backref='subject')
})
mapper(Mark, table_marks)
[skip ...](...)
mark = Mark()
s.save(mark)
mark.student = student_1
mark.subject = subject_1
mark.value = 5
s.flush()
Here is SQL output (shortened a bit for ease of reading):
SELECT * FROM marks WHERE 1 = marks.student_id <-----
unnecessary select
SELECT * FROM marks WHERE 1 = marks.subject_id <-----
unnecessary select
BEGIN
INSERT INTO marks (subject_id, student_id, value) VALUES (1, 1, 5)
COMMIT
the un-lazyloaded "marks" collections should remain un-lazyloaded when the backref event appends to them; they should instead place the object in a supplemental list, similar to that of DynamicInstrumentedAttribute
, which is merged with the collection when it is ultimately lazy loaded.
Comments (2)
-
reporter -
reporter - removed milestone
Removing milestone: 0.4.xx (automated comment)
- Log in to comment
9e4052dc8be2451d1c48bb059da150ce41ddc86f