[SQL-CVS] r729 - trunk/SQLObject/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2005-04-19 11:41:24
|
Author: phd
Date: 2005-04-19 11:41:17 +0000 (Tue, 19 Apr 2005)
New Revision: 729
Modified:
trunk/SQLObject/sqlobject/sqlbuilder.py
Log:
Fixed a bug - allow an aliased table to translate attribute name via
original table; for example alias.q.actID => "act_id".
Modified: trunk/SQLObject/sqlobject/sqlbuilder.py
===================================================================
--- trunk/SQLObject/sqlobject/sqlbuilder.py 2005-04-18 15:04:43 UTC (rev 728)
+++ trunk/SQLObject/sqlobject/sqlbuilder.py 2005-04-19 11:41:17 UTC (rev 729)
@@ -396,8 +396,14 @@
_alias_lock = threading.Lock()
_alias_counter = 0
- def __init__(self, tableName, alias=None):
+ def __init__(self, table, alias=None):
+ if hasattr(table, "sqlmeta"):
+ tableName = table.sqlmeta.table
+ else:
+ tableName = table
+ table = None
Table.__init__(self, tableName)
+ self.table = table
if alias is None:
self._alias_lock.acquire()
try:
@@ -410,12 +416,12 @@
def __getattr__(self, attr):
if attr.startswith('__'):
raise AttributeError
+ if self.table:
+ attr = getattr(self.table.q, attr).fieldName
return self.FieldClass(self.tableName, attr, self.alias)
class Alias:
def __init__(self, table, alias=None):
- if hasattr(table, "sqlmeta"):
- table = table.sqlmeta.table
self.q = AliasTable(table, alias)
|