Issue #3247121 by ramil g, joelpittet: Aggregation of nid when using COUNT produces syntax error
(cherry picked from commit bc8ed7fec1
)
merge-requests/2923/head
parent
904319041f
commit
f9e87b99e6
|
@ -1357,7 +1357,7 @@ class Sql extends QueryPluginBase {
|
||||||
$entity_information = $this->getEntityTableInfo();
|
$entity_information = $this->getEntityTableInfo();
|
||||||
if ($entity_information) {
|
if ($entity_information) {
|
||||||
$params = [];
|
$params = [];
|
||||||
if ($groupby) {
|
if ($this->hasAggregate) {
|
||||||
// Handle grouping, by retrieving the minimum entity_id.
|
// Handle grouping, by retrieving the minimum entity_id.
|
||||||
$params = [
|
$params = [
|
||||||
'function' => 'min',
|
'function' => 'min',
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
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
|
* @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.
|
* Modules to enable.
|
||||||
|
@ -79,6 +86,19 @@ class QueryGroupByTest extends ViewsKernelTestBase {
|
||||||
$this->assertEquals(3, $types['name2']);
|
$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.
|
* Provides a test helper which runs a view with some aggregation function.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue