-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
upsert doesn't catch errors #1553
Comments
"options": {
"validateUpsert": true
} Do you have this in your model settings? |
Thanks. Yes, I have it. |
Ah... well validation can include validating uniqueness. As far as errors thrown from the database, @raymondfeng do you have any thoughts? Missing an error thrown from the driver sounds like a large issue. |
Upsert fails silently when float number is sent to column defined as number with postgresql. I hope this example shows it. I have Strongloop model definition json file with column: "score": {
"type": "number"
} And I send PUT request with url /model (or /model/:id) containing body: {
"id":"1",
"score": 123.123
} The response will have status code 200 and the response body will have the updated score, but A GET request shows that the model got never updated. I can fix this by updating my model definition: "score": {
"type": "number",
"postgresql": {
"columnName": "score",
"dataType": "numeric",
"dataLength": null,
"dataPrecision": 10,
"dataScale": 5,
"nullable": "NO"
}
} Only catching and communicating this to my 3rd party users is tricky because they will assume everything worked fine. |
Just tripped into this as well. In my case trying to upsert when violating a unique key constraint is failing silently. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The upsert() method doesn't catch errors (duplicate key, foreign key, ...). The callback doesn't get error object, and gets the "updated" model instance. This happens in both cases (update or insert). I'm using MySQL.
The text was updated successfully, but these errors were encountered: