data
data copied to clipboard
Unhelpful assert if serializer leaves 'id' field as an integer
Thank you for opening this issue!
Hopefully, this issue template will help you provide us with enough information to assist in resolving the issue.
Reproduction
Description
If your JSONAPI serializer in a createRecord normalizeResponse hook does not convert the ID field in the JSON from the server into a string instead of an integer, you get something like the following assert:
index.js:172 Uncaught Error: Assertion Failed: Cannot update the id for 'plan:c028ff07-57b3-4281-98b0-ef285c16d3c7' from '5' to '5'.
It doesn't make sense and is quite unhelpful because there is only one call to createRecord so it gives the impression that the adapter is trying to change it twice and ember data is coughing over it.
I would expect it to either auto-convert it or spit out something like:"ID is not of the expected type"
Versions
3.16 Ember data and EMber
Run the following command and paste the output below: yarn list ember-source && yarn list ember-cli && yarn list --pattern ember-data
.
C:\inetpub\wwwroot\ember-roomviewer-bighomeshop>yarn list ember-source && yarn list ember-cli && yarn list --pattern ember-data
'yarn' is not recognized as an internal or external command,
operable program or batch file.
@Benjy1979 could you PR a test for this?
erm....ok I will attempt my first ever test
Are there any docs anywhere on how to "PR a test"? I'm not sure what a test is, is it a separate project with some test functions in it? Where do I put it when it's done?
The unhelpful message is coming out from ember.data and into the console so I'm not sure how to go about testing something like that.
@Benjy1979 the folders within packages/
are normal Ember addons/apps. Tests are located in packages/-ember-data/tests/
. There are a lot of examples there to look at. If you need any more guidance let me know :)