From 4cc5fb5d936d06b754a94a8ae81c44e47e44c853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Mon, 8 Jan 2007 21:29:24 +0000 Subject: [PATCH] don't use select_expression in countResults, because we are only interested in count(catalog.uid). (countResults with SearcheableText was broken) git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11947 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../erp5_mysql/z_count_results.xml | 16 +++++----------- product/ERP5Catalog/tests/testERP5Catalog.py | 10 +++++++++- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/CatalogMethodTemplateItem/portal_catalog/erp5_mysql/z_count_results.xml b/product/ERP5/bootstrap/erp5_core/CatalogMethodTemplateItem/portal_catalog/erp5_mysql/z_count_results.xml index 93b563c339..041188d898 100644 --- a/product/ERP5/bootstrap/erp5_core/CatalogMethodTemplateItem/portal_catalog/erp5_mysql/z_count_results.xml +++ b/product/ERP5/bootstrap/erp5_core/CatalogMethodTemplateItem/portal_catalog/erp5_mysql/z_count_results.xml @@ -69,11 +69,11 @@ <key> <string>_keys</string> </key> <value> <list> - <string>from_table_list</string> - <string>where_expression</string> - <string>select_expression</string> - <string>selection_domain</string> - <string>selection_report</string> +<string>from_table_list</string> +<string>where_expression</string> +<string>select_expression</string> +<string>selection_domain</string> +<string>selection_report</string> </list> </value> </item> @@ -136,9 +136,6 @@ selection_report</string> </value> SELECT\n COUNT(DISTINCT catalog.uid) <dtml-comment>We need subselect for better statistics</dtml-comment>\n -<dtml-if select_expression>\n - , <dtml-var select_expression>\n -</dtml-if>\n FROM\n <dtml-in from_table_list> <dtml-var sequence-item> AS <dtml-var sequence-key><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>\n <dtml-if selection_domain>\n @@ -210,9 +207,6 @@ ORDER BY\n SELECT\n COUNT(DISTINCT catalog.uid) <dtml-comment>We need subselect for better statistics</dtml-comment>\n -<dtml-if select_expression>\n - , <dtml-var select_expression>\n -</dtml-if>\n FROM\n <dtml-in from_table_list> <dtml-var sequence-item> AS <dtml-var sequence-key><dtml-if sequence-end><dtml-else>,</dtml-if></dtml-in>\n <dtml-if selection_domain>\n diff --git a/product/ERP5Catalog/tests/testERP5Catalog.py b/product/ERP5Catalog/tests/testERP5Catalog.py index bb70e58687..af702d94e8 100644 --- a/product/ERP5Catalog/tests/testERP5Catalog.py +++ b/product/ERP5Catalog/tests/testERP5Catalog.py @@ -1204,7 +1204,8 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): ob = folder.newContent() ob.setTitle('The title of this object') self.failUnless('this' in ob.SearchableText(), ob.SearchableText()) - # add some other objects, we + # add some other objects, we need to create a minimum quantity of data for + # full text queries to work correctly for i in range(10): otherob = folder.newContent() otherob.setTitle('Something different') @@ -1222,6 +1223,12 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): [x.getObject for x in self.getCatalogTool()( portal_type='Organisation', SearchableText='different')]) + # test countResults + self.assertEquals(1, self.getCatalogTool().countResults( + portal_type='Organisation', SearchableText='title')[0][0]) + self.assertEquals(0, self.getCatalogTool().countResults( + portal_type='Organisation', SearchableText='different')[0][0]) + def test_43_ManagePasteObject(self, quiet=quiet, run=run_all_test): if not run: return if not quiet: @@ -1257,3 +1264,4 @@ class TestERP5Catalog(ERP5TypeTestCase, LogInterceptor): [x.getObject() for x in self.getCatalogTool()( parent_title=person_module.getTitle())]) + -- 2.30.9