-
-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using a name for a user in an entity reference field, uid 0 gets chosen #278
Comments
Confirming on the issue with 2.3.0. The query is SELECT `base_table`.`uid` AS `uid`, `base_table`.`uid` AS `base_table_uid`
FROM `users` `base_table`
LEFT JOIN `users_field_data` `users_field_data` ON `users_field_data`.`uid` = `base_table`.`uid`
WHERE
(`users_field_data`.`uid` = '[email protected]')
OR
(`users_field_data`.`name` LIKE '[email protected]' ESCAPE '\\'); The troublesome condition is MariaDB [drupal]> SELECT 0 = '[email protected]';
+--------------------------+
| 0 = '[email protected]' |
+--------------------------+
| 1 |
+--------------------------+
1 row in set, 1 warning (0.000 sec) |
The commit in #241 has caused breaking changes when using entity reference labels and a postgres database. It appears to be same error - postgres throws
Ids can be integers or strings, so we need to first determine the id and value types, then build the query conditions based on that, e.g.
|
I am using a fairly out of the box setup with creating some users and then using them as entity references.
An excerpt from my steps:
This has been working quite fine, up until upgrading to v.2.3.0.
Now, the entity reference handler that expands the field chooses uid 0 instead. Basically it translates to an SQL query like so:
To me this looks quite OK, but for some reason this gives me 2 hits. One is the correct one, but the first one is uid 0.
I can easily reproduce it directly in my sql, without any test setup:
The warning generated is this:
I am probably not an SQL expert enough to tell you why it works like that, but it surely is a regression, and it totally breaks many many of my tests 😛
I see it was introduced with this #241
To me this indicates we could probably add an additional condition on uid not being 0 at least.
The text was updated successfully, but these errors were encountered: