[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 in 4d128af797 to 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 in 4d128af797 to 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:
Rufus Pollock
2013-06-15 12:12:15 +01:00
parent fa2e224bc9
commit 5d24fd474d
3 changed files with 42 additions and 18 deletions

View File

@@ -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],