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
Not able to find relationship id when order of objects is changed in the POST and PATCH requests #1276
Comments
Just to add, I am seeing a pattern here. Put all relationships in order of what columns are defined in the database. And then, put the last relationship (as per column order) at second last position. For eg. If my DB column order is |
Can you post the error you are seeing along with the full JSON body of the request as well as the HTTP URL? |
The JSON body pasted above is the complete request. I don't have any attributes in the class. It has only 3 relations as present in the request.
The response that I get is
When I see in my logs, it says that it inserting a null value for a relationship, and since I have NOT NULL defined at the DB level, the insert statement fails.
Request URL: http://localhost:8080/content/metadata |
Are you doing a POST or PATCH? |
this is a POST request PATCH has another problem. Request URL: http://localhost:8080/content/metadata Request:
Response:
|
The order of the relationships should not matter. |
For PATCH extension, every object must be assigned an ID (even if temporary) if you want to fixup relationships. |
PATCH extension docs don't include information on this - and probably should return a more meaningful error. I am going to file an issue to resolve that. I haven't seen the POST problem before. |
For the patch request, I have assigned an id - 1. Is there anything to do more? |
Do all of the other objects already exist that you are referencing in? |
Relationships must point to a pre-existing object - or one that you created in the same PATCH extension request. |
Yes, so when I change the order to ast, txnItm, txnGrp, it works absolutely fine |
What is the model for TaxonomyItem? |
Here is the model for taxonomyItem
|
Also - are you using an ORM like Hibernate to generate the schema? |
No, we are not using anything for schema generation. spring.jpa.properties.hibernate.ddl-auto = update |
Can you post your schemas - or alternatively - make a small project so I can debug? |
I misspoke on one point: {
"errors": [
"TransactionException: Cannot deserialize instance of `com.yahoo.elide.jsonapi.models.JsonApiDocument` out of START_ARRAY token\n at [Source: UNKNOWN; line: -1, column: -1]"
]
} means you are using the wrong content type for patch extension. JSON-API and the patch extension use different content types. Use application/vnd.api+json; ext=jsonpatch |
I have started using 4.6.1 and the bulk operation is succeeding fine now with Also, I have written all the relationships again. Not sure what has changed in 4.6.1 but the other issue is also working fine now. |
Expected Behavior
Hi Team,
I am getting a very weird issue while POST and PATCH (BULK) request. When the relationship order is changed in the JSON request, it is not able to find the id of the object (can be any of the three) in relationship with. Is it the correct behavior? Does the order of relationship matters in the request?
Steps to Reproduce (for bugs)
Your Environment
The text was updated successfully, but these errors were encountered: