When a view has the "node: distinct" filter, the node counts on "empty argument" summaries can be wrong (higher than the actual number of corresponding nodes)

The attached patch (against HEAD - could use a 4.7 backport ?) turns count(node.nid) into count(DISTINCT node.nid) if the 'node: distinct' filter is set for the view.

Note : There may be a better way to detect the 'node: distinct' filter - the 'array_reduce' method in this patch feels kind of hackish...

CommentFileSizeAuthor
#1 views_query.inc_2_0.patch989 bytesyched
views_query.inc_5.patch1.59 KByched
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

FileSize
989 bytes

Update - Actually this patch might be better.

yched’s picture

Status: Active » Needs review
merlinofchaos’s picture

Hmm. count($primary_fields) seems ok.

Though it may be better to actually create a flag on the query. If it's been set distinct, we can just check, and apply logic at a later point.

merlinofchaos’s picture

Status: Needs review » Fixed

I applied this as is, though; better to at least get this in and possibly work out the ramifications of distinct on the future.

Anonymous’s picture

Status: Fixed » Closed (fixed)