Always assign record IDs before other attributes in Spine.Model::load() #435

merged 3 commits into from Mar 19, 2013


None yet

2 participants

Spine JS Project member

This is basically a redo of the #171 PR which is now a bit stale. I also included more tests for and another bug fix for when model instances are passed into .load().

The original bug:

Album.hasMany 'photos', Photo
Photo.belongsTo 'album', Album

album = new Album();
    name: 'My Album',
    photos: [{
        id: '123',
        name: 'Picture of a cat'
    id: '456' # <= Triggers Bug!

Because id comes after photos, there's no parent record ID assigned yet to resolve the relation.

The other bug fix is exactly the same as #423

@aeischeid aeischeid was assigned Mar 19, 2013
@aeischeid aeischeid merged commit f1e1e06 into spine:master Mar 19, 2013
Spine JS Project member

I was holding off on #423 has own property thing because I was a little nervous how it might affect some of the relation stuff, but since you know that pretty well and are submitting this I am going to assume that should be okay, or that if it causes problems you won't blame me ;)

Spine JS Project member

As always, thanks for the pull request!

@adambiggs adambiggs deleted the adambiggs:assign-record-ids-first branch Mar 25, 2013
@adambiggs adambiggs restored the adambiggs:assign-record-ids-first branch Mar 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment