Commit 106a3276 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

an appropriate group_by_expression is required for MySQL-5.0.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25755 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 531b3054
......@@ -3813,6 +3813,7 @@ VALUES
portal_catalog = self.getCatalogTool()
res = portal_catalog.searchResults(
select_expression='count(DISTINCT catalog.reference) AS count_reference',
group_by_expression='catalog.reference',
)
self.assertEquals(1, len(res))
......
  • Doesn't this completely defeats the point of count(DISTOINCT catalog.reference) ?

    If we are already groupped by reference, then what is the expected outcome of this DISTINCT? All values are 1 ?

    Do you remember the purpose of this test ? (where would such feature be used ?)

  • The test itself was added in ab0f9b4e so removing DISTINCT will make this test completely meaningless.

    Having GROUP BY or not here has different meaning as below, but I don't remember which was my intention to test here...

    (With GROUP BY, having DISTINCT or not in COUNT has no difference, this is true as you wrote).

    MariaDB [erp5_test_0]> select distinct reference from catalog;
    +----------------------+
    | reference            |
    +----------------------+
    | NULL                 |
    | BarcodeUtils         |
    | BaseMigration        |
    | GeographicalArea     |
    | GeographicalPoint    |
    | Login                |
    | PersonLoginMigration |
    +----------------------+
    7 rows in set (0.00 sec)
    
    MariaDB [erp5_test_0]> select count(distinct reference) from catalog ;
    +---------------------------+
    | count(distinct reference) |
    +---------------------------+
    |                         6 |
    +---------------------------+
    1 row in set (0.00 sec)
    
    MariaDB [erp5_test_0]> select count(distinct(reference)) from catalog group by reference;
    +----------------------------+
    | count(distinct(reference)) |
    +----------------------------+
    |                          0 |
    |                          1 |
    |                          1 |
    |                          1 |
    |                          1 |
    |                          1 |
    |                          1 |
    +----------------------------+
    7 rows in set (0.01 sec)
    
    MariaDB [erp5_test_0]> select count(reference) from catalog group by reference;
    +------------------+
    | count(reference) |
    +------------------+
    |                0 |
    |                1 |
    |                1 |
    |                1 |
    |                1 |
    |                1 |
    |                1 |
    +------------------+
    7 rows in set (0.00 sec)
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