Commit e952b40d authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Support group_by_list and order_by_list in WebSection_getDocumentValueList.

Now you can sort results by full text search score, for example.
parent bdcdaca8
......@@ -140,6 +140,11 @@ try:\n
kw[\'effective_date\'] = effective_date\n
\n
if not all_versions:\n
group_by_list = list(kw.get(\'group_by_list\', []))\n
if all_languages:\n
kw[\'group_by_list\'] = group_by_list + [\'reference\', \'language\']\n
else:\n
kw[\'group_by_list\'] = group_by_list + [\'reference\',]\n
return current_section.WebSection_zGetDocumentValueList(language=language,\n
all_languages=all_languages,\n
src__=src__,\n
......
......@@ -64,9 +64,7 @@ kw</string> </value>
<key> <string>src</string> </key>
<value> <string encoding="cdata"><![CDATA[
<dtml-let query="buildSQLQuery(query=portal_catalog.getSecurityQuery(**kw), **kw)"\n
is_translation_order_by="query[\'order_by_expression\'] is not None and\n
\'translated_message\' in query[\'order_by_expression\']"\n
<dtml-let query="buildSQLQuery(query=portal_catalog.getSecurityQuery(**kw), auto_extend_select_list=True, **kw)"\n
selection_domain="kw.get(\'selection_domain\', None)"\n
selection_report="kw.get(\'selection_report\', None)">\n
\n
......@@ -76,12 +74,6 @@ kw</string> </value>
this method should be refactored to use catalog only.\n
\n
The subquery is named catalog to prevent use another LEFT JOIN.\n
\n
XXX This query heavily depends on MySQL implementation, \n
as it seems that the "GROUP BY reference" returns the first line of the subselect \n
(which is the expected one due to "ORDER BY priority DESC").\n
But, without any explicit reference of this behaviour in MySQL\n
documentation, wrong results may be returned with another MySQL version.\n
</dtml-comment>\n
\n
SELECT\n
......@@ -102,9 +94,7 @@ kw</string> </value>
WHEN \'en\' THEN \'2\'\n
ELSE \'1\' END,\n
my_versioning.version) AS priority\n
<dtml-if is_translation_order_by>\n
, related_translation_intermediate.translated_message\n
</dtml-if>\n
<dtml-if "query[\'select_expression\']">,<dtml-var "query[\'select_expression\']"></dtml-if>\n
FROM\n
<dtml-in prefix="table" expr="query[\'from_table_list\']">\n
<dtml-var table_item> AS <dtml-var table_key>,\n
......@@ -116,9 +106,6 @@ kw</string> </value>
<dtml-var "portal_selections.buildSQLJoinExpressionFromDomainSelection(selection_report)">,\n
</dtml-if>\n
versioning AS my_versioning\n
<dtml-if is_translation_order_by>\n
, translation AS related_translation_intermediate\n
</dtml-if>\n
WHERE\n
my_versioning.uid = catalog.uid\n
<dtml-if "query[\'where_expression\']">\n
......@@ -134,34 +121,17 @@ kw</string> </value>
<dtml-else>\n
AND my_versioning.language IN (<dtml-sqlvar language type="string">, \'\')\n
</dtml-if>\n
\n
<dtml-if is_translation_order_by>\n
AND catalog.validation_state = related_translation_intermediate.original_message\n
</dtml-if>\n
\n
ORDER BY\n
priority DESC\n
\n
) AS catalog\n
<dtml-if "\'versioning\' in query[\'order_by_expression\'] or all_languages">\n
, versioning\n
WHERE catalog.uid = versioning.uid\n
</dtml-if>\n
\n
<dtml-if all_languages>\n
GROUP BY reference, language\n
<dtml-else>\n
GROUP BY reference\n
<dtml-if "query[\'group_by_expression\']">\n
GROUP BY <dtml-var "query[\'group_by_expression\']">\n
</dtml-if>\n
\n
<dtml-if "query[\'order_by_expression\']">\n
ORDER BY\n
<dtml-if is_translation_order_by>\n
translated_message\n
<dtml-else>\n
<dtml-var "query[\'order_by_expression\']">\n
</dtml-if>\n
</dtml-if>\n
ORDER BY <dtml-var "query[\'order_by_expression\'] or \'priority DESC\'">\n
\n
<dtml-if "query[\'limit_expression\']">\n
LIMIT <dtml-var "query[\'limit_expression\']">\n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment