-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
User throws _id error when calling update user api call in MySQL #1135
Comments
@piere129 I think there is a pull request to prevent id duplication (the |
Hello @piere129 your suggestion will break mongoose application. We have to know why you have _id with SQL database. It's strange. |
@lauriejim I'm not sure what you mean? SQL only has one ID column |
@piere129 if your proposition work for Mongoose and Bookshelf generated applications feel free to submit a PR. Check out the contributing guide to get started: https://github.com/strapi/strapi/blob/master/.github/CONTRIBUTING.md |
I just got the same error as #1037 but with a mongoose database when calling GET /user/:id , looking into what could be the issue |
@omar1989omb could it be that your error: |
@piere129 did you have this issue when you try to update data which have been created with and old version of Strapi ? |
@piere129 Did you try with a new fresh app from |
I am closing this issue because we don’t have any update/needed informations about it. |
Informations
What is the current behavior?
Updating a User with the api call '/user/:id' throws the following error in MySQL:
{"statusCode":400,"error":"Bad Request","message":"select
users-permissions_user.* from
users-permissions_userwhere
users-permissions_user.
_id= '2' limit 1 - ER_BAD_FIELD_ERROR: Unknown column 'users-permissions_user._id' in 'where clause'"}
. Updating User in the Admin UI does work however. I also noticed using the api call from frontend does not allow you to update the username alone: it throws an error that the Email is already taken, which makes sense because it doesn't need to be edited.Steps to reproduce the problem
What is the expected behavior?
User should be updated
Suggested solutions
I'm posting an issue because I'm not sure how to do a pull request. I fixed the problem by navigating to ./plugins/services/User and editing the fetch method:
return strapi.query('user', 'users-permissions').findOne(_.pick(params, [ 'id', '_id']));
became
return strapi.query('user', 'users-permissions').findOne(_.pick(params, [ 'id']));
After this it worked as intended :) I know this is a fix on MySQL but I'm not sure about how this fix would work on Mongo databases, but it should at least point to the right direction for fixing this issue!
The text was updated successfully, but these errors were encountered: