This may be caused by the same underlying problem as #134375 but I'm not sure. And in this case I'm not using CCK.

I'm using a custom module with custom views integration. My view has one argument, with "sorted as view" option chosen. I've written the code for both the argument, and two of the fields shown in the view.

My fields are counts. That is, they have 'notafield' set to true, and they have a query_handler which looks something like:

function sample_bee_count_query_handler($field, $info, &$query) {
  $query->ensure_table("sunflower_sample_data");
  $query->add_field("COUNT(sunflower_sample_data.bee_weight)", NULL, "bee_count");
  $query->add_groupby("sunflower_sample_data.nid");
}

Notice the add_groupby(). It turns out this group by clause is added to the summary query as well, making multiple group bys there. And the combined groupbys cause some of my nodes to appear multiple times in the summary.

I don't see why views is adding the field queries for the summary. I can see why it would if the summary option were 'display all values'. But when 'sorted as view' is selected, this seems unnecessary. Unless you're trying to get the fields' default sorts in there. Hmmm.. just thought of that.

Anyway, any suggestions for how to solve this problem would be appreciated. Thanks.

Comments

Thomas Sewell’s picture

Have you tried adding the filter "Node: Distinct" to your view? It's designed to solve nodes showing up more than once in results.

merlinofchaos’s picture

Thanks to Postgres, the 'sorted as view' option is very dangerous; it can really harm summaries. Unfortunately, I have to recommend against using 'sorted as view' with summaries. This option may or may not be removed in the future. Still have to figure out what to do with it.

To explain, Postgres compatibily requires that all fields in an ORDER BY clause are also in the SELECT clause. This can cause harm to GROUP BY clauses, which summaries use. At this point, it is only safe to sort summaries ascending or descending.

merlinofchaos’s picture

Title: Summary shows same node multiple times. » Use of "Summary, sort as view" can cause duplicate summarie entries

Changing title to be more appropriate.

merlinofchaos’s picture

Status: Active » Fixed

This option was eventually removed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.