Hello,

While testing to reproduce a bug in the JSON API issue queue, I found an error provoked by dynamic entity reference #2841850-4: Internal Server Error with Grouped Filter Conditions while I was not requesting a dynamic entity reference field.

Steps to reproduce:

  1. On a Drupal site with the JSON API and the dynamic entity reference modules enabled
  2. maybe optional: Set a content type with a dynamic entity reference field
  3. Request a JSON API endpoint on a different content type with a filter on a referenced entity value. See https://www.drupal.org/node/2803141, "Filtering examples", case 2 "Nested Filters: Get nodes created by user admin", the URL would look like: jsonapi/node/page?filter[name-filter][condition][path]=uid.name&filter[name-filter][condition][value]=admin

There is a fatal error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node_field_data.uid_int' in 'on clause': SELECT base_table.vid AS vid, base_table.nid AS nid
FROM
{node} base_table
INNER JOIN {node_field_data} node_field_data ON node_field_data.nid = base_table.nid
LEFT OUTER JOIN {users} users ON users.uid = node_field_data.uid_int
INNER JOIN {users_field_data} users_field_data ON users_field_data.uid = users.uid
WHERE (users_field_data.name LIKE :db_condition_placeholder_0 ESCAPE '\\') AND (node_field_data.type = :db_condition_placeholder_1)
GROUP BY base_table.vid, base_table.nid
LIMIT 51 OFFSET 0; Array
(
[:db_condition_placeholder_0] => admin
[:db_condition_placeholder_1] => article
)

Due to dynamic_entity_reference/src/Query/Tables.php.

I do not understand why this class is used as it is not a dynamic entity reference field that is required.

Thanks for any help, and I will be glad to provide a patch.

Comments

Grimreaper created an issue. See original summary.

jibran’s picture

Thank you, for reporting the bug. Currently, I'm busy with work and I'd not be able to create the patch. If you can create a patch with tests I'll be more than happy to review/commit it. If you need help you can ping @jhedstrom in IRC he has worked on this part of DER in #2808337: Make use of proposed entity table relationship refactor. There is also a plan of using decorator service instead of taking over entire EFQ service in #2835542: Utilize service decorator instead of taking over entire EFQ service.

jibran’s picture

Status: Active » Closed (duplicate)

This issue has been fixed in #2895963: The _int handling is applied to all revision fields during system_update_8400() please update to 8.x-2.0-alpha5

Grimreaper’s picture

Hello,

Confirming that it works (2.0.0-alpha6). Thanks.