-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Backbone polymorphism does not support two models with same ID #2043
Comments
It looks like you need a composite key. I created a plugin at https://github.com/caseywebdev/backbone-composite-keys but it hasn't been updated for 0.9.9. |
A specific temporary solution I can think of is to override the For a long term solution perspective, I'm concerned that this may require too much knowledge about the internals of how collection duplication filtering works, especially given that this functionality seems to have changed recently in both 0.9.9, and then again in the latest master branch. I'm also uncertain of the performance impact in scenarios where the collection has several models. |
@caseywebdev your plugin looks like a workable solution to this problem too. I'll give it a shot, thanks! |
Again, if you're on |
There's more discussion about this type of problem in #1558 which spawned caseywebdev's composite keys plugin |
@gabetax I actually just updated my plugin to work correctly with |
@caseywebdev I updated earlier today when I saw it, and it seems to be working well for me so far. 🎉 |
Following the polymorphic collection instructions in #793, there seems to be an issue if you have two different models types (saving to two different URLs, and ultimately two different database tables) with the same
id
I can understand why a collection would want to remove duplicate models of identical objects, but I think it's a reasonable use case to have a polymorphic collection that may have models of different classes but with the same id.
The main sticking point seems to be in
collection.get
, whichcollection.add
uses in its duplication check.Do you have any opinions on the best way to handle this polymorphism use case? Up until this one issue, the solution from #793 has felt easy and elegant to me.
The text was updated successfully, but these errors were encountered: