- attached 447.py
Adding the possibility to 'traverse' relations through the list-property
Issue #447
resolved
Like in the file I will attach (inspired by #441), let's have persons that may have cars that may have accidents (person 1---N car 1 ---N accident). Person has a property named "cars" and car a property named "accidents" (self-explaining I guess).
I would like to have the possibility to fetch the accidents of one person using:
for accident in personInstance.cars.accidents:
print accident
It is not possible now (at least, using this syntax and in only one select) because "cars" is a simple list. Maybe using a more intelligent and iterable structure?
Comments (4)
-
Account Deleted -
repo owner - marked as minor
its far clearer to just use regular python instead of implicit magic:
for car in personInstance.cars: for accident in car.accidents: print accident
if youre concerned about excessive selects, thats what eager loading / result set mapping is for.
-
repo owner - changed milestone to blue sky
-
repo owner - changed status to wontfix
also join() and a whole bunch of other ways to do this
- Log in to comment
Testing script