[SQL-CVS] r3710 - SQLObject/branches/0.9/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2008-12-08 13:41:56
|
Author: dan Date: 2008-12-08 06:41:52 -0700 (Mon, 08 Dec 2008) New Revision: 3710 Modified: SQLObject/branches/0.9/sqlobject/col.py Log: Fixed createSQL table constrains generation when table name includes the database name (contains a dot) Modified: SQLObject/branches/0.9/sqlobject/col.py =================================================================== --- SQLObject/branches/0.9/sqlobject/col.py 2008-12-08 13:41:31 UTC (rev 3709) +++ SQLObject/branches/0.9/sqlobject/col.py 2008-12-08 13:41:52 UTC (rev 3710) @@ -848,6 +848,7 @@ def mysqlCreateReferenceConstraint(self): sTName = self.soClass.sqlmeta.table + sTLocalName = sTName.split('.')[-1] other = findClass(self.foreignKey, self.soClass.sqlmeta.registry) tName = other.sqlmeta.table idName = other.sqlmeta.idName @@ -860,7 +861,7 @@ action = 'ON DELETE RESTRICT' else: action = '' - constraint = ('ALTER TABLE %(sTName)s ADD CONSTRAINT %(sTName)s_%(colName)s_exists ' + constraint = ('ALTER TABLE %(sTName)s ADD CONSTRAINT %(sTLocalName)s_%(colName)s_exists ' 'FOREIGN KEY (%(colName)s) ' 'REFERENCES %(tName)s (%(idName)s) ' '%(action)s' % @@ -868,7 +869,8 @@ 'colName': self.dbName, 'idName': idName, 'action': action, - 'sTName': sTName}) + 'sTName': sTName, + 'sTLocalName': sTLocalName}) return constraint def mysqlCreateSQL(self): |