[Modeling-cvs] ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer MySQLSQLExpression.py,1.7
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2003-12-15 15:05:03
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer In directory sc8-pr-cvs1:/tmp/cvs-serv10442/Modeling/DatabaseAdaptors/MySQLAdaptorLayer Modified Files: MySQLSQLExpression.py Log Message: Fixed bug #857803: mysql: invalid generated sql for complex qualifiers Index: MySQLSQLExpression.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/MySQLAdaptorLayer/MySQLSQLExpression.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** MySQLSQLExpression.py 10 Aug 2003 11:59:13 -0000 1.7 --- MySQLSQLExpression.py 15 Dec 2003 15:05:00 -0000 1.8 *************** *** 34,39 **** __version__='$Revision$'[11:-2] from Modeling.SQLExpression import SQLExpression, DateType, CharacterType ! from Modeling.logging import trace import string --- 34,40 ---- __version__='$Revision$'[11:-2] + from Modeling.DatabaseAdaptors.MySQLAdaptorLayer.mysql_utils import * from Modeling.SQLExpression import SQLExpression, DateType, CharacterType ! from Modeling.logging import trace, db_trace import string *************** *** 44,47 **** --- 45,49 ---- available SQL data types. """ + def columnTypeStringForAttribute(self, attribute): """ *************** *** 119,177 **** return values - def _addTableJoinsForAlias(self, alias, str): - """ - Changes the default way the Modeling.SQLExpression calculates SQL - statements for JOIN. - - The default produces:: - - table0 alias0 INNER JOIN [ (some other nested join) | table1 alias1 ] - ON (join condition) - - from which you get a syntax error from mysql. Instead, the previous - statement should be changed to:: - - [ (some other nested join) | table1 alias1 ] INNER JOIN table0 alias0 - ON (join condition) - - Source: http://www.mysql.com/doc/en/JOIN.html in ''User Comments'', - see the first comment. - - See initial bug report at: - https://sourceforge.net/tracker/index.php?func=detail&aid=614261&group_id=58935&atid=489335 - - """ - trace('alias: %s / str: %s'%(alias, str)) - relPaths=self._internals.relPathsComingFromAlias(alias) - aliases=map(lambda rp, self=self: self._internals.aliasForRelPath(rp), - relPaths) - - t=self._internals.entityExternalNameForAlias(alias)+' '+alias - - if not aliases: str+=t - processedAliases_total=[] - for boundAlias in aliases: - currentRelPath=self._internals.relPathForAlias(boundAlias) - trace('relPath for bound alias: %s'%(currentRelPath)) - str2, processedAliases=self._addTableJoinsForAlias(boundAlias, '') - if string.find(str2, 'JOIN')!=-1: - str+=' ( '+str2+' ) ' - else: - str+=str2 - str+=' '+self.sqlStringForJoinSemantic(self._internals.joinSemanticForRelPath(currentRelPath))+' ' - str+=t - str+=' ON ( ' - srcKeys=self._internals.sourceKeysForRelPath(currentRelPath) - dstKeys=self._internals.destinationKeysForRelPath(currentRelPath) - for idx in range(len(srcKeys)): - str+='%s.%s=%s.%s AND '%(alias, srcKeys[idx], boundAlias, dstKeys[idx]) - str=str[:-5]+' ) ' - processedAliases_total.extend(processedAliases) - - aliases.extend(processedAliases_total) - aliases.append(alias) - - return (str, aliases) - def prepareSelectCountExpressionWithAttributes(self, attributes,lock,fetchSpec): --- 121,124 ---- *************** *** 234,239 **** self._whereClauseString=self.sqlStringForQualifier(fullQualifier) - joinClause='' - # Do we join some tables? multiple_tables_joined=len(self.entityExternalNamesByAliases())>1 --- 181,184 ---- *************** *** 253,263 **** columnList=' COUNT(*) ' - fetchOrder=None whereClause=self.whereClauseString() # orderBy: see fetchSpec... orderByClause='' # tableList=self.tableListWithRootEntity(self.entity()) self.assembleSelectStatementWithAttributes(attributes=attributes, lock=lock, --- 198,211 ---- columnList=' COUNT(*) ' whereClause=self.whereClauseString() # orderBy: see fetchSpec... orderByClause='' + fetchOrder=None # tableList=self.tableListWithRootEntity(self.entity()) + # The join clause is now built, if necessary + joinClause=self.joinClauseString() + self.assembleSelectStatementWithAttributes(attributes=attributes, lock=lock, *************** *** 296,297 **** --- 244,250 ---- return SQLExpression.sqlStringForSelector(self, selector, value) + + if mysql_server_version()[:2]>=(4,0): + MySQLSQLExpression.SQL92_join=1 + else: + MySQLSQLExpression.SQL92_join=0 |