Actually I didn't drop the test, because the old code were iterating on all classes again. In my iteration, I iterate on a copy of the already assembled tablesRegistry.

I found out that the problem is exactly on this part of the code:

-                        if tableRegistry.has_key(currentClass):
-                            #DSM: Must keep the last parent needed
-                            #DSM: (to limit the number of join needed)
-                            tableRegistry[registryClass] = currentClass
-                            #DSM: Remove this class as it is a parent one
-                            #DSM: of a needed children
-                            del tableRegistry[currentClass]
-                        currentClass = currentClass.sqlmeta.parentClass

In this code, if we have a tableRegistry with classes A, B and C (as I explained in the last email), if B is BEFORE C on allClasses dictionary, the code removes A from tableRegistry upon B iteration and when it iterates on C, there's no A anymore, resulting in a wrong associantion {C: B} and not the correct {C: A}

My code iterates on a copy and checks all of them, even if they were excluded from the resulting list.

Regarding the lastParent, that is wrong indeed. I forgot to remove that line.

It's quite difficult to reproduce the problem because it happens when the dictionary is in a specific order, but I'll try to reproduce it. Anyway, I've been very successful on my code after this patch is applied.


2006/10/31, Oleg Broytmann <>:

On Fri, Oct 27, 2006 at 12:37:40AM -0300, Raphael Derosso Pereira wrote:
> This one does, but has a strange behaviour: The parent descendent joins are
> getting dupplicated.

   Could it be because you've dropped the test
                if registryClass.sqlmeta.table in tablesDict:

   Also you have created
                lastParent  = parentClass
   but is is not used anywhere. What is the purpose of it?

   Can you produce a short test that shows the problem being fixed?

     Oleg Broytmann    
           Programmers don't die, they just GOSUB without RETURN.

Raphael Derosso Pereira
Engenheiro da Computação
icq: 4517421
Phone: +55 41 3024-7430
Cel: +55 41 9661-4442