[SQL-CVS] r2031 - SQLObject/trunk/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2006-10-26 15:55:31
|
Author: phd
Date: 2006-10-26 09:55:32 -0600 (Thu, 26 Oct 2006)
New Revision: 2031
Modified:
SQLObject/trunk/sqlobject/main.py
Log:
Fixed a bug in the duplicate names test - the test must exclude columns
from the parent classes in case of simple inheritance.
Modified: SQLObject/trunk/sqlobject/main.py
===================================================================
--- SQLObject/trunk/sqlobject/main.py 2006-10-24 16:29:07 UTC (rev 2030)
+++ SQLObject/trunk/sqlobject/main.py 2006-10-26 15:55:32 UTC (rev 2031)
@@ -319,10 +319,17 @@
"add the column %r"
% (soClass.__module__, soClass.__name__, name,
sqlmeta.columnDefinitions[name], columnDef))
- assert name not in dir(soClass), (
- "The class %s.%s already has a variable or method %r, you cannot "
- "add the column %r"
- % (soClass.__module__, soClass.__name__, name, name))
+ # Collect columns from the parent classes to test
+ # if the column is not in a parent class
+ parent_columns = []
+ for base in soClass.__bases__:
+ if hasattr(base, "sqlmeta"):
+ parent_columns.extend(base.sqlmeta.columns.keys())
+ if name in dir(soClass):
+ assert name in parent_columns, (
+ "The class %s.%s already has a variable or method %r, you cannot "
+ "add the column %r"
+ % (soClass.__module__, soClass.__name__, name, name))
sqlmeta.columnDefinitions[name] = columnDef
sqlmeta.columns[name] = column
# A stable-ordered version of the list...
|