When going to the Top Page report, I get the following:

PDOException: SQLSTATE[42703]: Undefined column: 7 ERROR: column "count" does not exist LINE 1: SELECT ads.path AS path, ads.title AS title, count AS count,... ^: SELECT ads.path AS path, ads.title AS title, count AS count, COUNT(*) AS count, MAX(timestamp) AS last FROM {adsense_clicks} ads GROUP BY path ORDER BY count DESC LIMIT 50 OFFSET 0; Array ( ) in PagerDefault->execute() (line 79 of /home/nj8j/public_html/includes/pager.inc).

This comes from the following code in adsense_click.logs.inc:

  // Create our base query.
  $query = db_select('adsense_clicks', 'ads');
  $query = $query->extend('PagerDefault')->extend('TableSort');

  $query
    ->fields('ads', array('path', 'title'))
    ->groupBy('path')
    ->limit(50)
    ->orderByHeader($header);

  $count = $query->addExpression('COUNT(*)', 'count');
  $max = $query->addExpression('MAX(timestamp)', 'last');

  $result = $query->execute();

From the generated SQL, it appears to be a problem with an extraneous 'count AS count' field, as there is no 'count' field in adsense_clicks. PostgreSQL complains about the missing table field (possibly MySQL allows this?(MySQL is often a lot more lax than PostgreSQL)).

From what I've gathered from #922030: TableSort issue with expressions, this appears to be a long-standing (since 2010) issue between the use of TableSort, and the use of addExpression. It isn't looking like it's going to be fixed real soon. Perhaps this should be recoded to avoid this issue?

(BTW, there's also a lurking PostgreSQL-compatibility issue in the background, as PostgreSQL will insist on both 'path' and 'title' being in the GROUP BY).

Comments

Ben Coleman created an issue. See original summary.

Ben Coleman’s picture

Issue summary: View changes
jcnventura’s picture

Title: PDO Exception on Top Page report » adsense_click: PDO Exception on Top Page report
Status: Active » Postponed

If someone finds a way to fix this, I'm willing to change it.. But the adsense_click module is a legacy sub-module that is broken in many other ways.

jcnventura’s picture

Title: adsense_click: PDO Exception on Top Page report » adsense_click + PostgreSQL: PDO Exception on Top Page report