Skip to content

Instantly share code, notes, and snippets.

@chadmoone
Created June 13, 2011 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chadmoone/1023734 to your computer and use it in GitHub Desktop.
Save chadmoone/1023734 to your computer and use it in GitHub Desktop.
Bug in SC.Record or SC.Store
// ==========================================================================
// Project: RecordBug
// Copyright: @2011 My Company, Inc.
// ==========================================================================
/*globals RecordBug */
RecordBug = SC.Application.create({
store: SC.Store.create().from(SC.Record.fixtures)
});
RecordBug.Person = SC.Record.extend({
name: SC.Record.attr(String)
});
RecordBug.Friend = RecordBug.Person.extend({
nickname: SC.Record.attr(String)
});
RecordBug.Client = RecordBug.Person.extend({
company: SC.Record.attr(String)
});
RecordBug.Friend.FIXTURES = [
{ guid: 1,
name: "Lorem",
nickname: "this"
},
{ guid: 2,
name: "Ipsum",
nickname: "is"
},
{ guid: 3,
name: "Dolor",
nickname: "an example"
}
];
RecordBug.Client.FIXTURES = [
{ guid: 1,
name: "Lorem",
company: "this"
},
{ guid: 2,
name: "Ipsum",
company: "is"
},
{ guid: 3,
name: "Dolor",
company: "an example"
}
];
SC.ready(function() {
RecordBug.mainPane = SC.TemplatePane.append({
layerId: 'record_bug',
templateName: 'record_bug'
});
var before = RecordBug.store.find(RecordBug.Person);
SC.Logger.log('before: '+ before.length()); // Should be 6, will be 0
var longQ = RecordBug.store.find([RecordBug.Friend, RecordBug.Client]);
SC.Logger.log('longQ: '+ longQ.length()); // Should be 6, is 6
var after = RecordBug.store.find(RecordBug.Person);
SC.Logger.log('after: '+ after.length()); // Same as first query, but now it's 6
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment