So I create two content types and in one of them do entity reference to another.
First content type is Employee and second Location.
In Location I add text field Amenities (Unlimited).
In Employee I do entity reference for Location.
When I add all fields in Views
views
everityng work good.
After I add field Amenities and don`t see data so I add RELATIONSHIP
views

after that all data disapear
views

I add to field referenship
views
views
so I see data from joint field but main data not there
views

Query before add RELATIONSHIP

SELECT node__field_first_n.field_first_n_value AS node__field_first_n_field_first_n_value, node__field_last_name.field_last_name_value AS node__field_last_name_field_last_name_value, node.nid AS nid
FROM 
{node} node
INNER JOIN {node_field_data} node_field_data ON node.nid = node_field_data.nid
LEFT JOIN {node__field_first_n} node__field_first_n ON node_field_data.nid = node__field_first_n.entity_id AND (node__field_first_n.deleted = '0' AND node__field_first_n.langcode = node_field_data.langcode)
LEFT JOIN {node__field_last_name} node__field_last_name ON node_field_data.nid = node__field_last_name.entity_id AND (node__field_last_name.deleted = '0' AND node__field_last_name.langcode = node_field_data.langcode)
WHERE (( (node_field_data.status = '1') AND (node.type IN  ('employee')) ))
ORDER BY node__field_first_n_field_first_n_value ASC
LIMIT 10 OFFSET 0

Query after add RELATIONSHIP

SELECT node__field_first_n.field_first_n_value AS node__field_first_n_field_first_n_value, node__field_last_name.field_last_name_value AS node__field_last_name_field_last_name_value, node_node__field_location.nid AS node_node__field_location_nid
FROM 
{node} node
INNER JOIN {node_field_data} node_field_data ON node.nid = node_field_data.nid
LEFT JOIN {node__field_location} node__field_location ON node_field_data.nid = node__field_location.entity_id AND (node__field_location.deleted = '0' AND node__field_location.langcode = node_field_data.langcode)
LEFT JOIN {node} node_node__field_location ON node__field_location.field_location_target_id = node_node__field_location.nid
LEFT JOIN {node__field_first_n} node__field_first_n ON node_field_data.nid = node__field_first_n.entity_id AND (node__field_first_n.deleted = '0' AND node__field_first_n.langcode = node_field_data.langcode)
LEFT JOIN {node__field_last_name} node__field_last_name ON node_field_data.nid = node__field_last_name.entity_id AND (node__field_last_name.deleted = '0' AND node__field_last_name.langcode = node_field_data.langcode)
WHERE (( (node_field_data.status = '1') AND (node.type IN  ('employee')) ))
ORDER BY node__field_first_n_field_first_n_value ASC
LIMIT 10 OFFSET 0

I see node.nid AS nid not in second query

Comments

Codenator’s picture

Ask any questions for further explanations

dawehner’s picture

So your view filters by employers by default. If you add a relationship which is not required you get a lot of rows back, which all have no content.

Please try out the following things:

  • Set the relationship to required ... you should see nothing
  • Set the filter to filter by locations, you should see what you expect.
Codenator’s picture

I try do as @dawehner tell me and got crash views

Exception: No entity type for field type on view employee_s_list in Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 716 of core\modules\views\src\Plugin\views\HandlerBase.php).

Try recreate views

berdir’s picture

Category: Bug report » Support request
Priority: Critical » Normal

This is not a critical bug, IMHO a normal support request until we actually know if and what is broken.

Codenator’s picture

Thanks @Berdir

Codenator’s picture

StatusFileSize
new121.21 KB
new18.43 KB

As mentored @dawehner not work I try diferents way

I try again as before
view

and find out tile shoving but not shoving anothers fields
view

Codenator’s picture

If really I am wrong can same one explain better.
For reproduce create two content types and in add 3-4 simple text fields in each
In one content type add entity reference
After that try to display data from another content.

bforchhammer’s picture

This sounds like it could be the same issue as in #2383197: Entities not loaded for relationships on same entity type.

@Codenator: If you're still experiencing your problem, maybe you can check out the patch in the referenced issue and see if that fixes your problem.

Codenator’s picture

Status: Active » Closed (fixed)

Seem that this issue gone! Closed.