Skip to content

Commit a7983de

Browse files
authored
Merge pull request #400 from janfh/feature/csv_delimiter
New configuration option to select csv column delimiter
2 parents c326b3f + 05a1a8c commit a7983de

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@
152152
"Use the column name",
153153
"Use the column label\n'Extended metadata' must be set to true in the JDBC configuration"
154154
]
155+
},
156+
"vscode-db2i.codegen.csvColumnDelimiter": {
157+
"type": "string",
158+
"description": "Delimiter",
159+
"default": "Comma",
160+
"enum": [
161+
"Comma",
162+
"Semicolon",
163+
"Tab"
164+
]
155165
}
156166
}
157167
},

src/views/results/contributes.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
"Use the column name",
4444
"Use the column label\n'Extended metadata' must be set to true in the JDBC configuration"
4545
]
46+
},
47+
"vscode-db2i.codegen.csvColumnDelimiter": {
48+
"type": "string",
49+
"description": "Delimiter",
50+
"default": "Comma",
51+
"enum": [
52+
"Comma",
53+
"Semicolon",
54+
"Tab"
55+
]
4656
}
4757
}
4858
}

src/views/results/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ export interface ParsedStatementInfo extends StatementInfo {
3939
embeddedInfo: ParsedEmbeddedStatement;
4040
}
4141

42+
const DelimValue = {
43+
Comma: `,`,
44+
Semicolon: `;`,
45+
Tab: `\t`
46+
}
47+
4248
export function setCancelButtonVisibility(visible: boolean) {
4349
vscode.commands.executeCommand(`setContext`, `vscode-db2i:statementCanCancel`, visible);
4450
}
@@ -414,10 +420,13 @@ async function runHandler(options?: StatementInfo) {
414420
case `sql`:
415421
let content = ``;
416422
switch (statementDetail.qualifier) {
417-
case `csv`: content = csv.stringify(data, {
418-
header: true,
419-
quoted_string: true,
420-
}); break;
423+
case `csv`:
424+
content = csv.stringify(data, {
425+
header: true,
426+
quoted_string: true,
427+
delimiter: DelimValue[Configuration.get<string>(`codegen.csvColumnDelimiter`) || `Comma`]
428+
});
429+
break;
421430
case `json`: content = JSON.stringify(data, null, 2); break;
422431

423432
case `sql`:

0 commit comments

Comments
 (0)