-
-
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
[BUGFIX identifiers] Address issue with polymorphic findRecord #7325
Conversation
Ok, I narrowed it down to the fact that Let me know if I should add some more tests. I'd be happy to consider alternative approaches as well. |
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.
Very nice PR! Looks like your tests cover when REQUEST_SERVICE is on and off.
Thanks for the approve. Yeah, that integration test is very high level. Sounds like this is going to be merged? I can create a PR into |
packages/-ember-data/tests/integration/identifiers/polymorphic-scenarios-test.ts
Show resolved
Hide resolved
@igorT @runspired do either of you see any issues with the implementation? Broadly this LGTM |
@krasnoukhov thanks a bunch for looking into this, great job dealing with the complex codebase without prior experience. I have run into this issue previously, and added a fix for the case handling it here:
I am wondering why this doesn't trigger the merge, it should conceptually be handled by the merge function. @snewcomer do you mind taking a look with @krasnoukhov to see why it doesn't get triggered |
Thanks @igorT. I stumbled upon that code as well. I tried adding |
@snewcomer lets figure out why |
I took a look at the cache and here are my thoughts. Seems to me this is the right solution. An alternative would be in |
To clarify further, without these changes, the identifier created further upstream looks like this. As a result, the However, with these changes, not setting the If we set the Lastly, simply commenting and not making any conclusions - I noticed one other thing. The |
👋 @krasnoukhov Igor presented another solution. Although your solution is a great idea and perhaps cleaner (is getting the lid correct further upstream better? I would assume so), the 👇 aligns us closer with how the current system works. Notice the surrounding code deals with mismatches as well. Let us know your thoughts (still one thing to deal with on a partner test but close to ready)!! |
Thanks @igorT and @snewcomer! Huge 🤦 moment for me since I assumed I think this alternative solution is definitely much more cleaner in a sense that identifier update handling stays close together. Nice work and I appreciate your help with digging into this |
Closing in favor of #7363 |
Hello! I found this issue while updating our app from 3.12 to 3.16. Previously it was possible to use
findRecord
to retrieve a specific instance of polymorphic model through the "base" model endpoint. This is useful when only the id is known but not the specific type. There was a prior fix in #6644 but the difference in this case is that there's no cache (through thedealership
) yet.So far I'm only adding a failing test which runs into this assertion:
data/packages/store/addon/-private/identifiers/cache.ts
Lines 519 to 524 in 78162a0
My next thought was to remove that assertion (since TODO says that it may be problematic), and I tried that, but I have a feeling that'd not be a complete fix since
foundFerrari.constructor.modelName
in the test resolves tocar
and notferrari
. I checked this on 3.12 and I believe it should beferrari
. UPD: visible in this CI runI tried digging into the source but I'm a little bit lost really so any feedback would be appreciated. I hope we can address this and backport into 3.16.
Thank you!