Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search user by email #288

Merged

Conversation

AdrienClairembault
Copy link
Contributor

@AdrienClairembault AdrienClairembault commented Jun 10, 2022

Using this simple CSV file containing users login and emails (imagine real emails instead of **** 馃槄):

image

The goal is, for each row, to find the user with the matching email and update its login.

Here is the model we are using:

image

The import will fail because datainjection doesn't seem to handle users search by email very well:

image

The query has no chance to succeed as it is looking for a foreign key that doesn't exist (and with an incorrect value - the raw email wouldn't be a valid foreign key anyway):

SELECT * FROM `glpi_users` WHERE 1 AND `is_deleted` = '0' AND `useremails_id`='*****@*****'

The correct query would be:

SELECT * FROM `glpi_users` WHERE 1 AND `is_deleted` = '0' AND `id` IN (
    SELECT `user_id` FROM glpi_useremails WHERE `email` = '*****@*****'
);

To fix this, I've added a specific check for this special case of searching users by email.

Internal ref: !24192

Co-authored-by: C茅dric Anne <cedric.anne@gmail.com>
@cedric-anne cedric-anne merged commit ba3b5e8 into pluginsGLPI:develop Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants