[#286,bugfix]: fix for case where fields array has nulls in it.

If passed fields = [ null, ..., ...] or [ ... , null, ...] we fail in Dataset._normalizeRecordsAndFields method because:

1. If null is first element we do not do field generation correctly because typeof(null) is object - ede211646a/src/model.js (L108)
2.  We call toString on field names which fails for null ede211646a/src/model.js (L113)
This commit is contained in:
Rufus Pollock
2012-12-09 18:58:52 +00:00
parent f093fcebfe
commit 5a322e2c7c
2 changed files with 11 additions and 6 deletions

View File

@@ -180,21 +180,22 @@ test('_normalizeRecordsAndFields', function () {
records: null
},
},
// non-string fields
{
in_: {
fields: [ 1, 1, 3 ],
records: null
fields: [ null, 1, 1, 3 ],
records: [ [1,2,3,4] ]
},
exp: {
fields: [
{id: '_noname_'},
{id: '1'},
{id: '11'},
{id: '3'}
],
records: null
records: [ { '_noname_': 1, '1': 2, '11': 3, '3': 4 } ]
},
},
// field is *not* a string
// records array but no fields
{
in_: {