Skip to content

Commit 0c8390c

Browse files
committed
Fix quoting of string columns in csv
1 parent d41c63b commit 0c8390c

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

extensions/ql-vscode/src/pure/bqrs-cli-types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,14 @@ export function transformBqrsResultSet(
103103
};
104104
}
105105

106+
type BqrsKind = 'String' | 'Float' | 'Integer' | 'String' | 'Boolean' | 'Date' | 'Entity';
107+
108+
interface BqrsColumn {
109+
name: string;
110+
kind: BqrsKind;
111+
}
106112
export interface DecodedBqrsChunk {
107113
tuples: CellValue[][];
108114
next?: number;
115+
columns: BqrsColumn[];
109116
}

extensions/ql-vscode/src/run-queries.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,12 @@ export class QueryEvaluationInfo {
358358
pageSize: 100,
359359
offset: nextOffset,
360360
});
361-
for (const tuple of chunk.tuples) {
362-
out.write(tuple.join(',') + '\n');
363-
}
361+
const quotes = chunk.columns.map(col => col.kind === 'String' ? '"' : '');
362+
chunk.tuples.forEach((tuple) => {
363+
out.write(tuple.map((v, i) => {
364+
return `${quotes[i]}${v}${quotes[i]}`;
365+
}).join(',') + '\n');
366+
});
364367
nextOffset = chunk.next;
365368
}
366369
out.end();

0 commit comments

Comments
 (0)