When adding a role reference field to a relationship in a view I get this error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_customer_groups.rid' in 'on clause'

This is the query:

SELECT node.created AS node_created, node.nid AS nid
FROM
{node} node
LEFT JOIN {field_data_field_customer_groups} field_data_field_customer_groups ON node.nid = field_data_field_customer_groups.entity_id AND (field_data_field_customer_groups.entity_type = 'node' AND field_data_field_customer_groups.deleted = '0')
LEFT JOIN {role} role_field_data_field_customer_groups ON field_data_field_customer_groups.rid = role_field_data_field_customer_groups.rid
WHERE (( (node.status = '1') AND (node.type IN ('produkt')) ))
ORDER BY node_created DESC

There is no field "rid" in the table field_data_field_customer_groups. Instead there is a "field_customer_groups_rid".

So THIS query DOES work:

SELECT node.created AS node_created, node.nid AS nid
FROM
{node} node
LEFT JOIN {field_data_field_customer_groups} field_data_field_customer_groups ON node.nid = field_data_field_customer_groups.entity_id AND (field_data_field_customer_groups.entity_type = 'node' AND field_data_field_customer_groups.deleted = '0')
LEFT JOIN {role} role_field_data_field_customer_groups ON field_data_field_customer_groups.field_customer_groups_rid = role_field_data_field_customer_groups.rid
WHERE (( (node.status = '1') AND (node.type IN ('produkt')) ))
ORDER BY node_created DESC

Not sure what module's issue this is though.

Comments

l0calh0rst’s picture

Maybe I found it. Please review:

rolereference.module (line 227):

Search:

'field' => 'rid',

Replace with:

'field' => $columns['rid'],
juliakoelsch’s picture

Thanks, @l0calh0rst! Ran into this issue too, and your change fixed it for me as well.

mykhailo.levchenko’s picture

Created patch according to the l0calh0rst's comment.

alex liannoy’s picture

Thank you, everybody.
Closing the issue.

alex liannoy’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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