From faadbbfa0bb352f33bea83ed9636fd7d4744e613 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Fri, 12 Apr 2013 16:55:56 +0200
Subject: [PATCH] Add left join support to coordinate related keys

---
 .../z_related_child_address.xml                  | 16 ++++++++--------
 .../z_related_child_telephone.xml                | 16 ++++++++--------
 .../z_related_default_email.xml                  |  7 ++++---
 bt5/erp5_base/bt/revision                        |  2 +-
 4 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_child_address.xml b/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_child_address.xml
index a15c0a1e26..c36b1a302b 100644
--- a/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_child_address.xml
+++ b/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_child_address.xml
@@ -9,7 +9,9 @@
         <item>
             <key> <string>arguments_src</string> </key>
             <value> <string>table_0\r\n
-table_1</string> </value>
+table_1\r\n
+query_table="catalog"\r\n
+RELATED_QUERY_SEPARATOR=" AND "</string> </value>
         </item>
         <item>
             <key> <string>connection_id</string> </key>
@@ -23,13 +25,11 @@ table_1</string> </value>
             <key> <string>src</string> </key>
             <value> <string encoding="cdata"><![CDATA[
 
-<dtml-comment>\n
-table_0 : catalog as child\n
-table_1 : address as address\n
-</dtml-comment>\n
-catalog.uid = <dtml-var table_0>.parent_uid\n
-AND <dtml-var table_0>.portal_type = \'Address\'\n
-AND <dtml-var table_0>.uid =  <dtml-var table_1>.uid
+<dtml-var table_0>.uid = <dtml-var table_1>.uid\n
+<dtml-var RELATED_QUERY_SEPARATOR>\n
+ <dtml-var table_0>.portal_type = \'Address\'\n
+AND <dtml-var query_table>.uid = <dtml-var table_0>.parent_uid\n
+
 
 ]]></string> </value>
         </item>
diff --git a/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_child_telephone.xml b/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_child_telephone.xml
index 14438e49d9..656664e841 100644
--- a/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_child_telephone.xml
+++ b/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_child_telephone.xml
@@ -9,7 +9,9 @@
         <item>
             <key> <string>arguments_src</string> </key>
             <value> <string>table_0\r\n
-table_1</string> </value>
+table_1\r\n
+query_table="catalog"\r\n
+RELATED_QUERY_SEPARATOR=" AND "</string> </value>
         </item>
         <item>
             <key> <string>connection_id</string> </key>
@@ -23,13 +25,11 @@ table_1</string> </value>
             <key> <string>src</string> </key>
             <value> <string encoding="cdata"><![CDATA[
 
-<dtml-comment>\n
-table_0 : catalog as child\n
-table_1 : telephone as telephone\n
-</dtml-comment>\n
-catalog.uid = <dtml-var table_0>.parent_uid\n
-AND <dtml-var table_0>.portal_type = \'Telephone\'\n
-AND <dtml-var table_0>.uid =  <dtml-var table_1>.uid
+<dtml-var table_0>.uid = <dtml-var table_1>.uid\n
+<dtml-var RELATED_QUERY_SEPARATOR>\n
+ <dtml-var table_0>.portal_type = \'Telephone\'\n
+AND <dtml-var query_table>.uid = <dtml-var table_0>.parent_uid\n
+
 
 ]]></string> </value>
         </item>
diff --git a/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_default_email.xml b/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_default_email.xml
index b5b1aa8487..7f25bd0495 100644
--- a/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_default_email.xml
+++ b/bt5/erp5_base/CatalogMethodTemplateItem/portal_catalog/erp5_mysql_innodb/z_related_default_email.xml
@@ -10,7 +10,8 @@
             <key> <string>arguments_src</string> </key>
             <value> <string>table_0\r\n
 table_1\r\n
-query_table</string> </value>
+query_table="catalog"\r\n
+RELATED_QUERY_SEPARATOR=" AND "</string> </value>
         </item>
         <item>
             <key> <string>connection_id</string> </key>
@@ -25,10 +26,10 @@ query_table</string> </value>
             <value> <string encoding="cdata"><![CDATA[
 
 <dtml-var table_0>.uid = <dtml-var table_1>.uid\n
-AND <dtml-var table_0>.parent_uid = <dtml-var query_table>.uid\n
+<dtml-var RELATED_QUERY_SEPARATOR>\n
+ <dtml-var table_0>.parent_uid = <dtml-var query_table>.uid\n
 AND <dtml-var table_0>.portal_type = \'Email\'\n
 AND <dtml-var table_0>.id = \'default_email\'\n
-\n
 
 
 ]]></string> </value>
diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision
index 09fef806d9..b25dcc8ec2 100644
--- a/bt5/erp5_base/bt/revision
+++ b/bt5/erp5_base/bt/revision
@@ -1 +1 @@
-1035
\ No newline at end of file
+1036
\ No newline at end of file
-- 
2.30.9