-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Links related relationship on modelA nulls belongsTo on modelB #5209
Comments
Can you update this ember-twiddle so it demonstrates the issue you're having? That would help greatly track down the issue your having! Thanks! |
I've filed a very similar issue: #5211, it's either related or duplicated. I've provided a reproduction twiddle. |
Here is a twiddle that I believe is the same issue as the OP: The application route loads a given user, loads a given organisation, then loads the user's organisation (should be the same as the given org). If you omit the "links" from the payload in |
I can confirm this behaviour in a real world app |
I'm working on a PR |
I have a failing test based on @williamhector 's twiddle... |
Found the problem - the payload data is cached until you read the relationship. Because you've not defined the inverse on one side, the second one is stomping on it - we need to keep the two relationships separate when defining the second end of the relationship. |
Fixed in #5257 |
I believe this has been fixed by #5230. Feel free to reopen if it is still an issue. |
Data Model
hasMany('modelB')
belongsTo('modelA')
model_a_id: 'model-a-1'
/api/model-a/:id
returns the model and/api/model-a/:id/model-b
returns the set of related modelB.Steps to reproduce
modelB.get('modelA')
is a fulfilled promise withnull
for contentExpected result
modelB should maintain its relationship with modelA despite modelA being loaded with unknown IDs for its hasMany modelB.
Actual result
The relationship is null and the original ID from the payload is now lost.
Notes
This only happens in this order. If modelB's modelA is already loaded, it seems to be fine.
The text was updated successfully, but these errors were encountered: