fix mutation returning when relationships are present (fix #1576) #1703
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Affected components
Related Issues
fix #1576
Solution and Design
If
returningfield contains nested selections then mutation is performed in two stepsreturningfields are queried on rows returned by selecting from table by filtering with column values returned in Step 1.Since mutation takes two courses based on selecting relations in
returningfield, it is hard to maintain sequence of prepared arguments (PrepArg) generated while resolvingreturningfield. So, we're usingtxtConverterinstead ofprepareto resolve mutation fields.Steps to test and verify
For typical
author-articleschema:-Insert an article along with author and query
author along with its articlesinreturningfield. It must return inserted article.Query:-
Response:-
{ "data": { "insert_article": { "affected_rows": 2, "returning": [ { "content": "Content for Article 5", "author": { "name": "Author 5", "articles": [ { "content": "Content for Article 5", "id": 5, "title": "Article by Author 5" } ], "id": 5, "articles_aggregate": { "aggregate": { "count": 1 } } }, "id": 5, "title": "Article by Author 5" } ] } } }Limitations, known bugs & workarounds
Querying relations in
returningfield of mutation response and Inserting nested objects are strictly available to tables which has atleast oneprimary keydefined or oneunique constraintsdefined onnot nullcolumns