Failing test showing problem with order of nested models #461

Merged
merged 1 commit into from May 15, 2015

Conversation

Projects
None yet
2 participants
@philfreo
Collaborator

philfreo commented May 13, 2014

Model's collection children should be in the proper order during fetch w/remove: false, even if one of the children have already been initialized in the Store.

Fetching a Model that has nested models sometimes results in the children being out-of-order.

This test fails, but should pass.

If you remove { remove: false } from the fetch, it passes. However there's no good reason why remove: false should cause it to fail, and there other reasons why it could be important that remove: false remains. Also if you remove the initial Child.findOrCreate it passes, but this also shouldn't affect the order of the Parent's children.

@philfreo

This comment has been minimized.

Show comment Hide comment
@philfreo

philfreo May 20, 2014

Collaborator

Thoughts on this test, @PaulUithol ?

Collaborator

philfreo commented May 20, 2014

Thoughts on this test, @PaulUithol ?

@PaulUithol

This comment has been minimized.

Show comment Hide comment
@PaulUithol

PaulUithol May 15, 2015

Owner

Quite fishy indeed. Looking into it. Apparently, the foo2 model gets added to the relation on the call to parent.set as soon as it gets initialized. So it'll be the first child in the relation. Specifying remove:false prevents the set call from overwriting that order with the one specified in the call's arguments.

Owner

PaulUithol commented May 15, 2015

Quite fishy indeed. Looking into it. Apparently, the foo2 model gets added to the relation on the call to parent.set as soon as it gets initialized. So it'll be the first child in the relation. Specifying remove:false prevents the set call from overwriting that order with the one specified in the call's arguments.

@PaulUithol

This comment has been minimized.

Show comment Hide comment
@PaulUithol

PaulUithol May 15, 2015

Owner

Alright, close to a solution.. this problem is a side effect of the fix to minimize the calling of parse on collections (code around https://github.com/PaulUithol/Backbone-relational/blob/master/backbone-relational.js#L1025)

Owner

PaulUithol commented May 15, 2015

Alright, close to a solution.. this problem is a side effect of the fix to minimize the calling of parse on collections (code around https://github.com/PaulUithol/Backbone-relational/blob/master/backbone-relational.js#L1025)

PaulUithol added a commit that referenced this pull request May 15, 2015

Merge pull request #461 from elasticsales/master
Failing test showing problem with order of nested models

@PaulUithol PaulUithol merged commit b56db7c into PaulUithol:master May 15, 2015

PaulUithol added a commit that referenced this pull request May 15, 2015

Don't instantiate models added to a HasMany relation before
calling `set`, to prevent ordering problems. Fixes the failing
test added by #461.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment