Skip to content
Snippets Groups Projects
Verified Commit dde89e22 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3247121 by ramil g, joelpittet: Aggregation of nid when using COUNT produces syntax error

(cherry picked from commit bc8ed7fe)
parent 403eb8dd
No related branches found
No related tags found
No related merge requests found
......@@ -1352,7 +1352,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',
......
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
......@@ -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.
......@@ -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.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment