[csv,bugfix][s]: fix to csv backend to correct issue with header row appearing in data in case where fields passed explicitly.
* The bug was triggered by change in4d128af797to use model fields if explicitly provided * model.test.js illustrated issue (that new test was failing prior to changes to csv backend in this commit) * Issue was that CSV backend did not pass back fields option. Previously, if no fields provided from backend we extracted fields from first row of the returned records. With change in4d128af797to use model fields if provided we had an issue as we no longer removed first row for fields. * Fixed by having CSV backend explicitly extract fields and pass them back
This commit is contained in:
@@ -64,6 +64,19 @@ test("parseCSV - quotechar", function() {
|
||||
|
||||
});
|
||||
|
||||
test("parseCSV skipInitialRows", function() {
|
||||
var csv = '"Jones, Jay",10\n' +
|
||||
'"Xyz ""ABC"" O\'Brien",11:35\n' +
|
||||
'"Other, AN",12:35\n';
|
||||
|
||||
var array = recline.Backend.CSV.parseCSV(csv, {skipInitialRows: 1});
|
||||
var exp = [
|
||||
['Xyz "ABC" O\'Brien', '11:35' ],
|
||||
['Other, AN', '12:35' ]
|
||||
];
|
||||
deepEqual(exp, array);
|
||||
});
|
||||
|
||||
test("serializeCSV - Array", function() {
|
||||
var csv = [
|
||||
['Jones, Jay', 10],
|
||||
|
||||
@@ -194,6 +194,7 @@ test('fetch without and with explicit fields', function () {
|
||||
dataset.fetch();
|
||||
equal(dataset.fields.at(0).id, 'X');
|
||||
equal(dataset.fields.at(0).get('type'), 'number');
|
||||
equal(dataset.records.at(0).get('X'), 1);
|
||||
});
|
||||
|
||||
test('_normalizeRecordsAndFields', function () {
|
||||
|
||||
Reference in New Issue
Block a user