Given the following content type setup:

Artist
- Name ( text )
Album
- Artist ( nodereference: artist )

I am constructing a view of Album nodes, including data from the related Artist fields:

Relationships: "Content: Node reference: artist (field_artist)"
Filters: "Node: Type = Album"
Fields: "Node: Title", "(artist) Node: Title", "(artist) Content: Name"

This works properly, and generates the following join code:

LEFT JOIN content_type_album node_data_field_artist ON node.vid = node_data_field_artist.vid
INNER JOIN node node_node_data_field_artist ON node_data_field_artist.field_artist_nid = node_node_data_field_artist.nid
LEFT JOIN content_type_artist node_data_field_name ON node_node_data_field_artist.vid = node_data_field_name.vid 

However, if I add a sort criteria through the relationship, the table alias on Views' join breaks:

LEFT JOIN content_type_album node_data_field_artist ON node.vid = node_data_field_artist.vid
INNER JOIN node node_node_data_field_artist ON node_data_field_artist.field_artist_nid = node_node_data_field_artist.nid
LEFT JOIN content_type_artist node_data_field_name ON node.vid = node_data_field_name.vid

The sort fails and the view also results in NULL values for "(artist) Content: Name".

Comments

merlinofchaos’s picture

Status: Active » Fixed

Fixed in CVS. Silly relationships and their edge cases.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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