-
-
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
Use _scheduleFetch instead of _fetchRecord for belongsTo relationship #5671
Use _scheduleFetch instead of _fetchRecord for belongsTo relationship #5671
Conversation
In order to ensure coalesceFindRequests works for this case.
I added tests for this case - I hope in the right place, I wasn't entirely sure where to put this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the first test, the other tests need similar fixes.
assert.equal(type.modelName, 'tag', 'modelName is tag'); | ||
|
||
if (id === '3') { | ||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return resolve(...data...)
will make this appropriately return a promise.
}, | ||
}; | ||
} else if (id === '4') { | ||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, return a resolved promise
} | ||
}; | ||
|
||
return run(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using async ... await
instead of lots of run loops would clean this up nicely
|
||
env.adapter.coalesceFindRequests = false; | ||
|
||
run(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we make this an async test there is no need to wrap store.push
in run()
9c6f59f
to
bd92a47
Compare
I made the requested changes to the test (to be honest, I only used to non-async-await syntax because I tried to stick to the same test style as the existing tests in the file. async-await is soo much nicer)! |
bd92a47
to
10acf7f
Compare
…#5671) * Use _scheduleFetch instead of _fetchRecord for belongsTo relationship In order to ensure coalesceFindRequests works for this case. * Add tests for coalescing of belongsTo relationships
…#5671) * Use _scheduleFetch instead of _fetchRecord for belongsTo relationship In order to ensure coalesceFindRequests works for this case. * Add tests for coalescing of belongsTo relationships
…#5671) * Use _scheduleFetch instead of _fetchRecord for belongsTo relationship In order to ensure coalesceFindRequests works for this case. * Add tests for coalescing of belongsTo relationships
In order to ensure coalesceFindRequests works for this case.
Without this, it would trigger one find-request per belongsTo relationship, instead of correctly coalescing them together.
I have stumbled over this while trying to debug something else, and was pretty puzzled as to why it wasn't working as expected. Changing this fixed the issue for me - not sure if there is something I'm not seeing there, though.