[Modeling-cvs] ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer PostgresqlSQLExpress
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2003-08-03 10:34:17
|
Update of /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer In directory sc8-pr-cvs1:/tmp/cvs-serv21866/DatabaseAdaptors/PostgresqlAdaptorLayer Modified Files: PostgresqlSQLExpression.py Log Message: Fixed bug #780495: when ec.fetch() is joining two tables or more, the returned set of objects could have duplicates. Index: PostgresqlSQLExpression.py =================================================================== RCS file: /cvsroot/modeling/ProjectModeling/Modeling/DatabaseAdaptors/PostgresqlAdaptorLayer/PostgresqlSQLExpression.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PostgresqlSQLExpression.py 24 Jul 2003 12:07:25 -0000 1.5 --- PostgresqlSQLExpression.py 3 Aug 2003 10:34:14 -0000 1.6 *************** *** 92,95 **** --- 92,114 ---- return attribute.externalType() + def _prepareSelectExpressionWithAttributes(self, attributes, lock, + fetchSpec, count=0): + """ + Overrides the default behaviour and add the necessary + 'AS DISTINCT_ROWS' required by postgresql when dealing with sub-queries. + + This happens when parameter count is true (e.g. when + EditingContext.fetchCount() is called) and that the query corresponding + to fetchSpec implies that two tables or more are joined. + + """ + SQLExpression._prepareSelectExpressionWithAttributes(self, + attributes, lock, + fetchSpec, count) + if count: + select_distinct='SELECT COUNT(*) FROM ( SELECT DISTINCT ' + if self._statement[:len(select_distinct)]==select_distinct: + self._statement=self._statement+' AS DISTINCT_ROWS' + def sqlPatternFromShellPatternWithEscapeCharacter(self, pattern, escapeChar): """ |