Backbone-relational icon indicating copy to clipboard operation
Backbone-relational copied to clipboard

Backbone.Collection.add doesn't respect the { merge : true, at: <index> } option.

Open Sundarasan opened this issue 10 years ago • 4 comments

I want to merge and move a model to a particular index. When I pass the option { merge : true, at: 0 } it does merge but not moving the model to the given index.

Sundarasan avatar Mar 26 '15 08:03 Sundarasan

Hi @Sundarasan - can you provide a test case showing the expected (but broken) behavior?

philfreo avatar Apr 15 '15 20:04 philfreo

I believe there is a bug in backbone-relational's Collection.set implementation. The merge parameter is being overridden to false, but I can't think of any reason why it should be. Because of this existing model updates get dropped.

add(..., {merge: true}) works as expected when I remove this.

pmckinnon avatar May 15 '15 20:05 pmckinnon

Because at that point, updates should already have been merged into the model - through the _prepareModel->findOrCreate route. Do you maybe have an example where that doesn't happen? Removing the merge: false causes other tests to fail.

PaulUithol avatar May 15 '15 21:05 PaulUithol

I'm not seeing the updates getting in, I'll see if I can pin things down better.

pmckinnon avatar May 15 '15 22:05 pmckinnon