Skip to content

Commit

Permalink
fix: use json.stringify as value handler (bytebase#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Jan 20, 2022
1 parent 2f2716e commit 5442a3a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions frontend/src/views/SqlEditor/TablePanel/TableView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,18 @@ const handleExportBtnClick = (format: "csv" | "json") => {
if (format === "csv") {
let CSVContent = "";
CSVContent += columns.value.map((item) => String(item.key)).join(",");
CSVContent += columns.value
.map((item) => JSON.stringify(item.key))
.join(",");
CSVContent += "\n";
for (const d of data.value) {
const temp: any[] = [];
for (const k in d) {
temp.push(d[k]);
}
CSVContent += temp.map((item) => String(item)).join(",");
CSVContent += "\n";
CSVContent += temp.map((item) => JSON.stringify(item)).join(",");
CSVContent += "\r\n";
}
rawText = CSVContent;
Expand All @@ -173,8 +175,7 @@ const handleExportBtnClick = (format: "csv" | "json") => {
const encodedUri = encodeURI(`data:text/${format};charset=utf-8,${rawText}`);
const link = document.createElement("a");
// TODO: file name should be the current query name
link.download = `${Date.now()}.${format}`;
link.download = `${currentTab.value.label}.${format}`;
link.href = encodedUri;
link.click();
};
Expand Down

0 comments on commit 5442a3a

Please sign in to comment.