On Nov 29, 2007, at 12:25 PM, Kapil Thangavelu wrote:

> i'm attaching a script which demonstrates the issue, and a  
> contextual traceback (ipython) of the error.
>


ok, great...you got this one in r3844.  below i will try to explain  
this bug but feel free to just skip the explanation since its a little  
deep (and the bug was dumb anyway).


lets say you loaded "nodes" with a single self-referential eager load  
- the query is like:

select nodes.*, nodes_1.* from nodes left outer join nodes as nodes_1

and lets suppose data like:

n1 -> (n2, n3)
n2 -> (n4)
n3 -> ()
n4 -> ()

i.e. n1 has n2 and n3 for children, n2 has n4.

so heres some hypothetical rows (these line up in fixed width for  
those playing at home):

nodes.id | nodes.name | nodes_1.id | nodes_1.name
    1           n1           2             n2
    1           n1           3             n3
    2           n2           4             n4
    3           n3         null           null
    4           n4         null           null

so what happens ?  the mapper's eager loading process encounters the  
nodes represented uniquely in their rows in this order:

n1, n2, n3, n4, n2, n3, n4

"represented uniquely" means, we see a node in a particular row for a  
particular set of columns for the first time ever in the result set.   
that is normally the eager loader's cue to set up a collection on the  
parent to collect the child results.  but here, because of the self- 
referential eager, we encounter all of n2, n3, n4 in *two different*  
configurations - once in the "nodes.id, nodes.name" columns, and once  
in the "nodes_1.id, nodes_1.name" columns.  so the bug was, the second  
time n2, n3, n4 came around, the eager loader saw OK this instance is  
not new for this result, so let me pull out the appender and then  
there wasn't one - since the eager loader had already seen these  
instances in the "nodes_1" position and rejected further eager  
loading, since there was not a third level of columns.  so to fix the  
eager loader just creates the appender collection if not present.






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to