-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
DefaultCrudRepository#update stores invalid representation of array-typed property in PostgreSQL (Error: could not create List from JSON string) #2532
Comments
@chadmg, can you define the
See https://github.com/strongloop/loopback4-example-shopping/blob/master/src/models/order.model.ts#L29 for examples. |
@dhmlau Thanks for the reply! This didn't seem to change anything. Problem still occurs. Note: It only happens when using DefaultCrudRepository#update As a workaround I've replaced update with calls to delete then create and everything is working as expected. |
@dhmlau Any update on this? Seems like a pretty critical issue with Loopback if a simple update operation is storing invalid and unretrievable data in the DB. I don't think I'm doing anything wrong - please let me know if I am - but I don't understand how this isn't an issue for other users? |
Hi @chadmg , sorry about the delay. Let me run your scenario tomorrow and try the |
@chadmg, I was able to reproduce your problem. @bajtos, would it be part of the PATCH spike that you're looking into? |
@dhmlau To provide some more details, through testing I've found this issue happening with both DefaultCrudRepository#update and DefaultCrudRepository#updateById. Side question: Where are all of the docs for these methods? I'm not even sure what the difference between update and updateById are... it seems like loopback 4 docs are completely lacking on the persistence/ORM layer. |
@chadmg , thanks for the info. Yes, we're aware of the limitation for PATCH. As the first step, a spike is in progress for the support. Please join the discussion in: #2082. The API docs can be found in http://apidocs.loopback.io/. Unfortunately, looking at DefaultCrudRepository, it doesn't have much information. If you agree, I'd like to continue the discussion of the PATCH support in #2082, and we'll use this issue to see how we can improve our API docs. Contributions are welcomed! |
@chadmg , upateById under the hood is calling an replaceByID on the other hand just proxies the model The generated controller |
@marioestradarosa, thanks. Would you like to submit a PR to improve our API docs? Thanks. |
@dhmlau ok, I will do work on it this weekend 👍 |
Any update on this issue. I am having the exact same issue when updating through path request results the object array to be stored like this :
it works fine when creating the data but while updating it creates problems |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the |
Description
My model looks like this:
When I create an Order entity using a repository:
It stores the items array properly (in text column):
However when I try to update an Order that already exists:
The items array ends up being stored like this in the text column:
Then when I try to retrieve orders I get this error:
Current Behavior
Array property is being set to invalid string on update.
Expected Behavior
Update should treat array property same as create method does and store valid JSON.
The text was updated successfully, but these errors were encountered: