-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
This fixes duplicate key issue #649 #668
Conversation
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
@slnode ok to test |
Hi @BerkeleyTrue, thank you for submitting the patch. The solution looks too hacky to me, as it is using an internal juggler property. However, I don't know enough about the replication internals, I'll leave it up to @ritch to judge that. |
Agreed on the hacky-ness, but I could not find exactly where this flag is to be set. This got me thinking about how that flag is normally set. Turns out if you change line 415 in change.js
to
This also works, but I don't know what else this would affect. |
The new solution looks better to me. Please add a unit-test that fails without your patch and passes with your patch in place. |
Two more thoughts: This looks like a bug in the juggler to me. I would expect that I don't understand why we are creating a new change object in the first place, since we already have one. Is there any reason why the following should not work? this.find(function(err, changes) {
if (err) return cb(err);
changes.forEach(function(change) {
change.rectify();
});
}); |
Removed the instantiation line. All seems to work as expected. Are there test that need to be added? |
I am don't know if there is an easy way how to test your changes in isolation against in-memory database. We should ideally run the test suite against MongoDB, but that's out of scope of this PR. Could you please squash the commits and update the commit message? |
(Other than that, the patch LGTM.) |
Sorry, squash the commits? Not sure what that means. |
@BerkeleyTrue run Let me know if you need more help. |
+1 this patch does the trick |
This PR removes the instantiation of a new change model as models return from Change.find are already instances of Change. This solves the duplicate Id issue #649
That was fun. How does that look? |
@BerkeleyTrue Much better :) One more thing - I need you to sign our CLA, see https://cla.strongloop.com/agreements/strongloop/loopback. |
@slnode ok to test |
This fixes duplicate key issue #649
Landed, thank you for the contribution! |
Woot! |
change.rectify will call save without __persisted flag set.
This causes DAO to treat model as new instead of as
an existing model to update.