From 0c4cc4492afac6a27e1d49e75f86afaf1ce34b4d Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Wed, 11 Mar 2009 13:10:29 +0000
Subject: [PATCH] Add a special case for SearchableText: when there are
 mustiple MATCH subqueries, sum up all scores. This used to fail and should be
 the most sensible default behaviour.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25971 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ZSQLCatalog/SQLExpression.py | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/product/ZSQLCatalog/SQLExpression.py b/product/ZSQLCatalog/SQLExpression.py
index c3f6beb7cb..9fda41d4da 100644
--- a/product/ZSQLCatalog/SQLExpression.py
+++ b/product/ZSQLCatalog/SQLExpression.py
@@ -299,14 +299,18 @@ class SQLExpression(object):
       for alias, column in sql_expression.getSelectDict().iteritems():
         existing_value = result.get(alias)
         if existing_value not in (None, column):
-          message = '%r is a known alias for column %r, can\'t alias it now to column %r' % (alias, existing_value, column)
-          if DEBUG:
-            message = message + '. I was created by %r, and I am working on %r (%r) out of [%s]' % (
-              self.query,
-              sql_expression,
-              sql_expression.query,
-              ', '.join('%r (%r)' % (x, x.query) for x in self.sql_expression_list))
-          raise ValueError, message
+          if alias == 'SearchableText':
+            # Custom conflict resolution
+            column = '%s + %s' % (existing_value, column)
+          else:
+            message = '%r is a known alias for column %r, can\'t alias it now to column %r' % (alias, existing_value, column)
+            if DEBUG:
+              message = message + '. I was created by %r, and I am working on %r (%r) out of [%s]' % (
+                self.query,
+                sql_expression,
+                sql_expression.query,
+                ', '.join('%r (%r)' % (x, x.query) for x in self.sql_expression_list))
+            raise ValueError, message
         result[alias] = column
     return result
 
-- 
2.30.9