[SQL-CVS] r2059 - SQLObject/trunk/sqlobject/inheritance
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2006-10-31 17:44:09
|
Author: phd
Date: 2006-10-31 10:44:01 -0700 (Tue, 31 Oct 2006)
New Revision: 2059
Modified:
SQLObject/trunk/sqlobject/inheritance/__init__.py
Log:
A bugfix by Raphael Derosso Pereira <rap...@gm...> for a bug in InheritableSQLObject
related to the order of tableRegistry dictionary.
Modified: SQLObject/trunk/sqlobject/inheritance/__init__.py
===================================================================
--- SQLObject/trunk/sqlobject/inheritance/__init__.py 2006-10-31 10:19:15 UTC (rev 2058)
+++ SQLObject/trunk/sqlobject/inheritance/__init__.py 2006-10-31 17:44:01 UTC (rev 2059)
@@ -38,18 +38,21 @@
if registryClass.sqlmeta.table in tablesDict:
#DSM: By default, no parents are needed for the clauses
tableRegistry[registryClass] = registryClass
- for registryClass in allClasses:
- if registryClass.sqlmeta.table in tablesDict:
- currentClass = registryClass.sqlmeta.parentClass
- while currentClass:
- if tableRegistry.has_key(currentClass):
- #DSM: Must keep the last parent needed
- #DSM: (to limit the number of join needed)
- tableRegistry[registryClass] = currentClass
+ tableRegistryCopy = tableRegistry.copy()
+ for childClass in tableRegistryCopy:
+ if childClass not in tableRegistry:
+ continue
+ currentClass = childClass
+ while currentClass:
+ if tableRegistryCopy.has_key(currentClass):
+ if currentClass in tableRegistry:
#DSM: Remove this class as it is a parent one
#DSM: of a needed children
del tableRegistry[currentClass]
- currentClass = currentClass.sqlmeta.parentClass
+ #DSM: Must keep the last parent needed
+ #DSM: (to limit the number of join needed)
+ tableRegistry[childClass] = currentClass
+ currentClass = currentClass.sqlmeta.parentClass
#DSM: Table registry contains only the last children
#DSM: or standalone classes
parentClause = []
|