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
Fixed many2many empty relationships update case #112
Conversation
@tommikaikkonen any thought about that? |
I did not try this, but just from the naming of the variables I would expect that you no longer can update a relation from no entities to some entities? I submitted a fix for that about 2 months ago, which also includes some tests for the bug: #86 |
… ID and we want to update instead of create again
What do u mean when you say "No entities to some entities?" I am using this on a heavy app and it's working really well. |
I think i'm running into this issue too. |
I have a forked package with this fixed for testing called redux-orm-kerad until that pr is merged or someone brings light. Maybe it will help u |
@carlesnunez thanks for getting back to me on this! I created a test case to better express what I mean: it('updating related many-to-many entities from none to some works', () => {
const { Book, Genre } = session;
const book = Book.create({
name: 'My new Book',
genres: [],
});
expect(book.genres.toRefArray().map(row => row.id))
.to.deep.equal([]);
const addGenre = Genre.withId(2);
book.update({ genres: [addGenre] });
expect(book.genres.toRefArray().map(row => row.id))
.to.deep.equal([2]);
}); With your changes this fails with: 1) Integration Immutable session updating related many-to-many entities from none to some works:
AssertionError: expected [] to deeply equal [ 2 ]
+ expected - actual
-[]
+[
+ 2
+] The newly created book has no genres at first. If you try to add some later on the change will be discarded since I think that #86 fixed the error we are describing and this is now merged into master. Please let me now if I got you right on this! Considering that you opened another PR (#124) based on this functionality, maybe this PR here could be closed? |
Hello! Close that issue nad i'll check the new redux-orm version. Is it as a new npm version too? |
Unfortunately there is no new npm release yet. @tommikaikkonen any plans on releasing a new rc? |
Released. 👍 |
I notice that the the releases panel doesn't update,what happened? |
@NE-SmallTown hmm great note. There's a step I must have missed. I'll fix that up. 👍 |
The next PR fix a bug related with the update of relationships that doen't have the data. For example:
If we have a model called books that have alot of authors and:
Then the update function tries to do .add with id's that are not linked without any record and throw an error.
I propose the fix that follow in that PR