mirror of
https://github.com/danbulant/sql2csv
synced 2026-05-19 04:18:33 +00:00
Fix length v2
This commit is contained in:
parent
075a43e3aa
commit
a1d6fbc84e
1 changed files with 10 additions and 2 deletions
12
sql2csv.js
12
sql2csv.js
|
|
@ -76,8 +76,11 @@ class sql2csv {
|
|||
column = '"' + column + '"';
|
||||
}
|
||||
}
|
||||
if(current != last)
|
||||
if(current != last){
|
||||
csv += column + ",";
|
||||
} else {
|
||||
csv += column;
|
||||
}
|
||||
}
|
||||
keysEmpty = false;
|
||||
if(self.options.crlf) csv += "\r";
|
||||
|
|
@ -85,10 +88,15 @@ class sql2csv {
|
|||
});
|
||||
if(self.options.showNames){
|
||||
var header = "";
|
||||
var current = 0;
|
||||
var last = keys.length;
|
||||
keys.forEach((key) => {
|
||||
current++;
|
||||
key.replace('"', '""');//double quotes, regarding https://stackoverflow.com/questions/4617935
|
||||
key.replace(",", '","');
|
||||
header += key + ",";
|
||||
header += key;
|
||||
if(current != last)
|
||||
header += ",";
|
||||
});
|
||||
if(self.options.crlf) header += "\r";
|
||||
header += "\n";
|
||||
|
|
|
|||
Loading…
Reference in a new issue