Adding the possibility to 'traverse' relations through the list-property

Issue #447 resolved
Former user created an issue

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)

  1. Mike Bayer repo owner

    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.

  2. Log in to comment