Problem

PDOException: Integrity constraint violation: 1052 Column 'changed' in field list is ambiguous.

To reproduce:

    Content translation
  • enable Content translation (translation) module
  • enable entity_translation module
  • create a Relevant Content Block with
    • Display Options -> Order on -> select 'Any date option' OR with Filter Options -> Date Filter -> select 'Yes'
    • Filter Options -> Translation -> "Filter on user's language" selected
  • view the block
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'changed' in field list is ambiguous: 

SELECT node.nid AS entity_id, node.vid AS revision_id, node.type AS bundle, node.language AS language, 
	et.language AS et_language, et.status AS et_status, et.translate AS et_translate, :entity_type AS entity_type, 		
CASE node.type WHEN 'page' THEN changed 
			WHEN 'restricted_page' THEN created 
			WHEN 'webform' THEN created 
			WHEN 'building' THEN created 
			WHEN 'channel_event' THEN created 
			WHEN 'channel_news' THEN created 
			WHEN 'mprofile' THEN created 
			WHEN 'media_gallery' THEN created 
			WHEN 'campus' THEN created 
			ELSE '' END 
		AS sort_date
	FROM {node} node 
	LEFT OUTER JOIN {entity_translation} et ON et.entity_type = :base_table 
			AND et.entity_id = node.nid 
			AND et.language = :language 
	WHERE (node.nid <> :db_condition_placeholder_0) 
		AND (node.status = :db_condition_placeholder_1) 
		AND (node.type IN (:db_condition_placeholder_2))
		AND( (node.language = :db_condition_placeholder_3) OR (node.language = :db_condition_placeholder_4) O( (et.language = :db_condition_placeholder_5) 
		AND (et.status = :db_condition_placeholder_6) )) 
	ORDER BY sort_date ASC 
	LIMIT 10 OFFSET 0; 
in EntityFieldQuery->execute() (line 1216 of /srv/wpslabs/drupal7/includes/entity.inc).

This error occurs because both the node and the entity_translation tables have a 'changed' column.

Proposed resolution

Add table name to select fields to avoid ambiguity.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

karolinam created an issue. See original summary.

karolinam’s picture

Issue summary: View changes
karolinam’s picture

karolinam’s picture

Assigned: karolinam » Unassigned
Status: Active » Needs review
karolinam’s picture

Issue summary: View changes
FileSize
1.91 KB

Adding a fix for filtering by date.