Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293129

Aggregation of nid when counting fails

$
0
0

Problem/Motivation

Adding only a field with a COUNT aggregation on nid, adds a second nid without a GROUP BY clause resulting in this

SQLSTATE[42000]: Syntax error or access violation: 1140 In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'db.node_field_data.nid'; this is incompatible with sql_mode=only_full_group_by: SELECT "node_field_data"."nid" AS "nid_1", COUNT(node_field_data.nid) AS "nid" FROM "node_field_data""node_field_data" WHERE ("node_field_data"."status" = :db_condition_placeholder_0) AND ("node_field_data"."type" IN (:db_condition_placeholder_1)); Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => course_section )

This is a regression from D7 views as this would produce the COUNT only field.

Steps to reproduce

  1. Create a new node view on article bundle
  2. Remove sort clause that gets added and title field
  3. Turn on aggregation
  4. Add COUNT on nid field

Proposed resolution

Avoid adding the nid via getEntityTableInfo() when it's not needed, or add the appropriate GROUP By to the field it adds

@see
\Drupal\views\Plugin\views\query\entity_information
core/modules/views/src/Plugin/views/query/Sql.php:1344

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 293129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>