From 57ae0f42d98151a95f9b0ee5b2144825704c2eff Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Thu, 16 Apr 2009 08:12:15 +0000
Subject: [PATCH] Remove an useless JOIN.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26455 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../WebSection_zGetDocumentValueList.xml      | 64 +++++++++----------
 bt5/erp5_web/bt/revision                      |  2 +-
 2 files changed, 31 insertions(+), 35 deletions(-)

diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_zGetDocumentValueList.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_zGetDocumentValueList.xml
index acaa9dd327..b7dc716384 100644
--- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_zGetDocumentValueList.xml
+++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web/WebSection_zGetDocumentValueList.xml
@@ -176,6 +176,14 @@ kw</string> </value>
         my_versioning.version,\n
         catalog.creation_date,\n
         catalog.title,\n
+        <dtml-if all_versions>\n
+        <dtml-else>\n
+        CONCAT(CASE my_versioning.language\n
+                   WHEN <dtml-sqlvar language type="string"> THEN \'3\'\n
+                   WHEN \'en\' THEN \'2\'\n
+                   ELSE \'1\' END,\n
+            my_versioning.version) AS current_priority,\n
+        </dtml-if>\n
         MAX(CONCAT(CASE my_versioning.language\n
                    WHEN <dtml-sqlvar language type="string"> THEN \'3\'\n
                    WHEN \'en\' THEN \'2\'\n
@@ -207,23 +215,13 @@ kw</string> </value>
         catalog.uid\n
       ORDER BY\n
         priority DESC\n
-    ) AS catalog,\n
-      versioning AS my_versioning\n
+    ) AS catalog\n
 \n
-  WHERE\n
-    catalog.uid = my_versioning.uid\n
   <dtml-if all_versions>\n
-    GROUP BY\n
-      catalog.uid\n
   <dtml-else>\n
-    GROUP BY\n
-      catalog.reference\n
-    HAVING\n
-      MAX(CONCAT(CASE my_versioning.language\n
-                 WHEN  <dtml-sqlvar language type="string"> THEN \'3\'\n
-                 WHEN \'en\' THEN \'2\'\n
-                 ELSE \'1\' END,\n
-          my_versioning.version)) = catalog.priority\n
+    WHERE\n
+      catalog.priority = catalog.current_priority\n
+    GROUP BY reference\n
   </dtml-if>\n
 \n
   ORDER BY\n
@@ -233,9 +231,9 @@ kw</string> </value>
     <dtml-else>\n
       <dtml-var "query[\'order_by_expression\']">\n
     </dtml-if>\n
-  <dtml-else>\n
-    catalog.int_index,\n
-    catalog.reference\n
+  <dtml-else> \t \t \n
+     catalog.int_index,\n
+     catalog.reference\n
   </dtml-if>\n
 \n
   <dtml-if "query[\'limit_expression\']">\n
@@ -323,6 +321,14 @@ kw</string> </value>
         my_versioning.version,\n
         catalog.creation_date,\n
         catalog.title,\n
+        <dtml-if all_versions>\n
+        <dtml-else>\n
+        CONCAT(CASE my_versioning.language\n
+                   WHEN <dtml-sqlvar language type="string"> THEN \'3\'\n
+                   WHEN \'en\' THEN \'2\'\n
+                   ELSE \'1\' END,\n
+            my_versioning.version) AS current_priority,\n
+        </dtml-if>\n
         MAX(CONCAT(CASE my_versioning.language\n
                    WHEN <dtml-sqlvar language type="string"> THEN \'3\'\n
                    WHEN \'en\' THEN \'2\'\n
@@ -354,23 +360,13 @@ kw</string> </value>
         catalog.uid\n
       ORDER BY\n
         priority DESC\n
-    ) AS catalog,\n
-      versioning AS my_versioning\n
+    ) AS catalog\n
 \n
-  WHERE\n
-    catalog.uid = my_versioning.uid\n
   <dtml-if all_versions>\n
-    GROUP BY\n
-      catalog.uid\n
   <dtml-else>\n
-    GROUP BY\n
-      catalog.reference\n
-    HAVING\n
-      MAX(CONCAT(CASE my_versioning.language\n
-                 WHEN  <dtml-sqlvar language type="string"> THEN \'3\'\n
-                 WHEN \'en\' THEN \'2\'\n
-                 ELSE \'1\' END,\n
-          my_versioning.version)) = catalog.priority\n
+    WHERE\n
+      catalog.priority = catalog.current_priority\n
+    GROUP BY reference\n
   </dtml-if>\n
 \n
   ORDER BY\n
@@ -380,9 +376,9 @@ kw</string> </value>
     <dtml-else>\n
       <dtml-var "query[\'order_by_expression\']">\n
     </dtml-if>\n
-  <dtml-else>\n
-    catalog.int_index,\n
-    catalog.reference\n
+  <dtml-else> \t \t \n
+     catalog.int_index,\n
+     catalog.reference\n
   </dtml-if>\n
 \n
   <dtml-if "query[\'limit_expression\']">\n
diff --git a/bt5/erp5_web/bt/revision b/bt5/erp5_web/bt/revision
index 64c6e93534..35d29653bf 100644
--- a/bt5/erp5_web/bt/revision
+++ b/bt5/erp5_web/bt/revision
@@ -1 +1 @@
-779
\ No newline at end of file
+791
\ No newline at end of file
-- 
2.30.9