Fresh install without content. On page admin/content/comment I have this error and nothing more.

Error message
PDOException: SQLSTATE[HY000]: General error: 1 ambiguous column name: changed: SELECT n.title AS node_title, c.cid AS cid, c.subject AS subject, c.name AS name, c.changed AS changed FROM {comment} c INNER JOIN {node} n ON n.nid = c.nid WHERE (c.status = :db_condition_placeholder_0) ORDER BY changed DESC LIMIT 50 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1 ) in PagerDefault->execute() (line 93 of /Users/simon/Sites/drupal-7.0-alpha2/includes/pager.inc).
Files: 
CommentFileSizeAuthor
#12 731044_comment-admin-ambiguous-column-12.patch887 bytesSivaji
PASSED: [[SimpleTest]]: [MySQL] 25,909 pass(es). View

Comments

Crell’s picture

Component: sqlite database » comment.module

Sounds like someone is running a bad query on that page.

scottrouse’s picture

Version: 7.0-alpha2 » 7.0-alpha7

I'm still getting this error with a fresh install of 7.0-alpha7. When I click on Content in the admin menu, then click the Comments tab.

PDOException: SQLSTATE[HY000]: General error: 1 ambiguous column name: changed: SELECT n.title AS node_title, c.cid AS cid, c.subject AS subject, c.name AS name, c.changed AS changed FROM {comment} c INNER JOIN {node} n ON n.nid = c.nid WHERE (c.status = :db_condition_placeholder_0) ORDER BY changed DESC LIMIT 50 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1 ) in PagerDefault->execute() (line 80 of /Applications/MAMP/htdocs/d7/includes/pager.inc).

The website encountered an unexpected error. Please try again later.

Should this be a critical bug?

gagarine’s picture

Version: 7.0-alpha7 » 7.x-dev
Status: Active » Closed (cannot reproduce)

I tried with the head today and I have no more error.

pheudo’s picture

Version: 7.x-dev » 7.0-beta1
Status: Closed (cannot reproduce) » Active

Here the same error.

Maybe could it be SQLite?

Crell’s picture

What configuration are you running when you get the error? Is it only on SQLite? Can you try on MySQL and see if it still breaks?

Actually, looking at the query more closely it looks like the ORDER BY clause is the culprit. Both node and comment have a "changed" column, so the DB doesn't know which one to use. It could be that MySQL is smarter about figuring it out than SQLite is. Sounds like we need a patch for that query to be explicit about which one is intended.

webchick’s picture

I can't reproduce on MySQL. Must be a SQLite thing.

And fwiw we do have test coverage for this condition, it looks like:

    // Test that the comments page loads correctly when there are no comments
    $this->drupalGet('admin/content/comment');
    $this->assertText(t('No comments available.'));
Sivaji’s picture

Tested against beta and dev release with MySQL and sqlite3. I can not reproduce any error.

pheudo’s picture

I can't reproduce on MySQL too. Maybe a SQLite thing.

pheudo’s picture

It looks some matter with the changed field because is present into the node table too...
It's really strange.

  // Load the comments that need to be displayed.
  $status = ($arg == 'approval') ? COMMENT_NOT_PUBLISHED : COMMENT_PUBLISHED;
  $header = array(
    'subject' => array('data' => t('Subject'), 'field' => 'subject'),
    'author' => array('data' => t('Author'), 'field' => 'name'),
    'posted_in' => array('data' => t('Posted in'), 'field' => 'node_title'),
    'changed' => array('data' => t('Updated'), 'field' => 'changed', 'sort' => 'desc'),
    'operations' => array('data' => t('Operations')),
  );

  $query = db_select('comment', 'c')->extend('PagerDefault')->extend('TableSort');
  $query->join('node', 'n', 'n.nid = c.nid');
  $query->addField('n', 'title', 'node_title');
  $result = $query
    ->fields('c', array('cid', 'subject', 'name', 'changed'))
    ->condition('c.status', $status)
    ->limit(50)
    ->orderByHeader($header)
    ->execute();

If I comment changed header it works.
If I use c.changed instead it works too...

Crell’s picture

Hm. Let's try specifying c.changed in the header array and see if that fixes it. pheudo, can you roll a patch?

pheudo’s picture

But it doesn't explain why in some installation it works and in other we got error.
Maybe the PHP version (and the OCI sqlite extension bundled)?

I'm using 5.2.9 and I tried with the latest 5.2.14.
I didn't try with 5.3...

Sivaji’s picture

Status: Active » Needs review
FileSize
887 bytes
PASSED: [[SimpleTest]]: [MySQL] 25,909 pass(es). View

Attached is the patch replacing "changed" to "c.changed" in the header array.

Crell’s picture

Status: Needs review » Reviewed & tested by the community

#12 should go in either way for cleanliness if nothing else. Let's do that and see if SQLite is fixed as a result.

webchick’s picture

Version: 7.0-beta1 » 7.x-dev
Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks!

Status: Fixed » Closed (fixed)

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