Loading core/modules/views/src/Plugin/views/query/Sql.php +1 −1 Original line number Diff line number Diff line Loading @@ -1351,7 +1351,7 @@ public function query($get_count = FALSE) { $entity_information = $this->getEntityTableInfo(); if ($entity_information) { $params = []; if ($groupby) { if ($this->hasAggregate) { // Handle grouping, by retrieving the minimum entity_id. $params = [ 'function' => 'min', Loading core/modules/views/tests/modules/views_test_config/test_views/views.view.test_aggregate_count_function.yml 0 → 100644 +55 −0 Original line number Diff line number Diff line langcode: en status: true dependencies: { } id: test_aggregate_count_function label: '' module: views description: '' tag: '' base_table: entity_test base_field: id display: default: display_options: access: type: none arguments: { } cache: type: tag exposed_form: type: basic fields: id: alter: alter_text: false ellipsis: true html: false make_link: false strip_tags: false trim: false word_boundary: true empty_zero: false field: id group_type: count hide_empty: false id: id table: entity_test plugin_id: field type: number_integer entity_type: entity_test entity_field: id group_by: true pager: type: some query: options: query_comment: '' type: views_query style: type: default row: type: fields display_plugin: default display_title: Default id: default position: 0 core/modules/views/tests/src/Kernel/QueryGroupByTest.php +21 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,14 @@ class QueryGroupByTest extends ViewsKernelTestBase { * * @var array */ public static $testViews = ['test_group_by_in_filters', 'test_aggregate_count', 'test_group_by_count', 'test_group_by_count_multicardinality', 'test_group_by_field_not_within_bundle']; public static $testViews = [ 'test_group_by_in_filters', 'test_aggregate_count', 'test_aggregate_count_function', 'test_group_by_count', 'test_group_by_count_multicardinality', 'test_group_by_field_not_within_bundle', ]; /** * Modules to enable. Loading Loading @@ -79,6 +86,19 @@ public function testAggregateCount() { $this->assertEquals(3, $types['name2']); } /** * Tests aggregate count feature with no group by. */ public function testAggregateCountFunction() { $this->setupTestEntities(); $view = Views::getView('test_aggregate_count_function'); $this->executeView($view); $this->assertEquals(7, $view->result[0]->id); $this->assertCount(1, $view->result, 'Make sure the count of rows is one.'); } /** * Provides a test helper which runs a view with some aggregation function. * Loading Loading
core/modules/views/src/Plugin/views/query/Sql.php +1 −1 Original line number Diff line number Diff line Loading @@ -1351,7 +1351,7 @@ public function query($get_count = FALSE) { $entity_information = $this->getEntityTableInfo(); if ($entity_information) { $params = []; if ($groupby) { if ($this->hasAggregate) { // Handle grouping, by retrieving the minimum entity_id. $params = [ 'function' => 'min', Loading
core/modules/views/tests/modules/views_test_config/test_views/views.view.test_aggregate_count_function.yml 0 → 100644 +55 −0 Original line number Diff line number Diff line langcode: en status: true dependencies: { } id: test_aggregate_count_function label: '' module: views description: '' tag: '' base_table: entity_test base_field: id display: default: display_options: access: type: none arguments: { } cache: type: tag exposed_form: type: basic fields: id: alter: alter_text: false ellipsis: true html: false make_link: false strip_tags: false trim: false word_boundary: true empty_zero: false field: id group_type: count hide_empty: false id: id table: entity_test plugin_id: field type: number_integer entity_type: entity_test entity_field: id group_by: true pager: type: some query: options: query_comment: '' type: views_query style: type: default row: type: fields display_plugin: default display_title: Default id: default position: 0
core/modules/views/tests/src/Kernel/QueryGroupByTest.php +21 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,14 @@ class QueryGroupByTest extends ViewsKernelTestBase { * * @var array */ public static $testViews = ['test_group_by_in_filters', 'test_aggregate_count', 'test_group_by_count', 'test_group_by_count_multicardinality', 'test_group_by_field_not_within_bundle']; public static $testViews = [ 'test_group_by_in_filters', 'test_aggregate_count', 'test_aggregate_count_function', 'test_group_by_count', 'test_group_by_count_multicardinality', 'test_group_by_field_not_within_bundle', ]; /** * Modules to enable. Loading Loading @@ -79,6 +86,19 @@ public function testAggregateCount() { $this->assertEquals(3, $types['name2']); } /** * Tests aggregate count feature with no group by. */ public function testAggregateCountFunction() { $this->setupTestEntities(); $view = Views::getView('test_aggregate_count_function'); $this->executeView($view); $this->assertEquals(7, $view->result[0]->id); $this->assertCount(1, $view->result, 'Make sure the count of rows is one.'); } /** * Provides a test helper which runs a view with some aggregation function. * Loading