-
-
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
Make sure new record are not pushed twice when parent is saved before. #4154
Make sure new record are not pushed twice when parent is saved before. #4154
Conversation
@olivierchatry Does it also update the record again when new data is returned by the server (such as the id for example)? |
yes, it should. it was really because the same record would be pushed twice because of some handling of isNew in the relationship. You can also simply 'reload' the record every-time you save ( when ALL relations has been saved ) and it should fix the issue. |
Nice, would be cool to see this in core 👍 |
this.members.add(newRecords[i]); | ||
if (!this.members.has(newRecords[i])) { | ||
this.members.add(newRecords[i]); | ||
} |
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.
@olivierchatry did you run into an issue that required this if check? Under the hood members
does a similar check which should be preventing the record from being added twice.
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.
Yes, using firebase, record get duplicate, see test.
On Feb 12, 2016 1:29 AM, "Brendan McLoughlin" [email protected]
wrote:
In addon/-private/system/relationships/state/relationship.js
#4154 (comment):@@ -173,7 +173,9 @@ Relationship.prototype = {
//TODO(Igor) make this less abysmally slow
this.members = this.canonicalMembers.copy();
for (i=0; i<newRecords.length; i++) {
this.members.add(newRecords[i]);
if (!this.members.has(newRecords[i])) {
this.members.add(newRecords[i]);
}
@olivierchatry https://github.com/olivierchatry did you run into an
issue that required this if check? Under the hood members does a similar
check
https://github.com/emberjs/ember.js/blob/master/packages/ember-metal/lib/map.js#L113
which should be preventing the record from being added twice.—
Reply to this email directly or view it on GitHub
https://github.com/emberjs/data/pull/4154/files#r52690836.
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.
When I remove this if
check all of the tests still pass.
So, what do I need to do to make it OK ? |
3 things:
|
I will revert the relationship one as it is redundant. How do you want me On Fri, Feb 12, 2016 at 7:02 PM, Brendan McLoughlin <
|
@olivierchatry you can rebase your branch locally and then force push it to github and it will update this pr. Here is a good short tutorial on how to perform a rebase locally: https://egghead.io/lessons/javascript-how-to-squash-multiple-git-commits |
Am turning a bit crazy, wondering if it would not be easier to create a new branch and a new pull request from it. |
@olivierchatry Do the following commands to squash your stuff: git rebase -i HEAD~6 # 6 is how many commits you want to rebase It will open vim or something equalvant. Then replace Now make a good commit message, everything with Your history is now been altered to one single commit, now run |
a0640ef
to
d9c62c4
Compare
stupid me, was missing the -f on the push ... thanks a lot ! On Fri, Feb 12, 2016 at 10:19 PM, Steffen Brem [email protected]
|
…ch-has-many Make sure new record are not pushed twice when parent is saved before.
I notice this isn't in 2.5.0-beta1. Should we expect this to appear in a release soon? |
I'll make sure this gets included in the |
No description provided.