Skip to content

Commit bb0c53d

Browse files
authored
Display EntityValue labels in CSV export (#2170)
1 parent 82d0309 commit bb0c53d

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [UNRELEASED]
44

55
- Show data flow paths of a variant analysis in a new tab
6+
- Show labels of entities in exported CSV results [#2170](https://github.com/github/vscode-codeql/pull/2170)
67

78
## 1.8.0 - 9 March 2023
89

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { nanoid } from "nanoid";
3030
import { CodeQLCliServer } from "./cli";
3131
import { SELECT_QUERY_NAME } from "./contextual/locationFinder";
3232
import { DatabaseManager } from "./local-databases";
33-
import { DecodedBqrsChunk } from "./pure/bqrs-cli-types";
33+
import { DecodedBqrsChunk, EntityValue } from "./pure/bqrs-cli-types";
3434
import { extLogger, Logger } from "./common";
3535
import { generateSummarySymbolsFile } from "./log-insights/summary-parser";
3636
import { getErrorMessage } from "./pure/helpers-pure";
@@ -351,11 +351,17 @@ export class QueryEvaluationInfo {
351351
chunk.tuples.forEach((tuple) => {
352352
out.write(
353353
`${tuple
354-
.map((v, i) =>
355-
chunk.columns[i].kind === "String"
356-
? `"${typeof v === "string" ? v.replaceAll('"', '""') : v}"`
357-
: v,
358-
)
354+
.map((v, i) => {
355+
if (chunk.columns[i].kind === "String") {
356+
return `"${
357+
typeof v === "string" ? v.replaceAll('"', '""') : v
358+
}"`;
359+
} else if (chunk.columns[i].kind === "Entity") {
360+
return (v as EntityValue).label;
361+
} else {
362+
return v;
363+
}
364+
})
359365
.join(",")}\n`,
360366
);
361367
});

0 commit comments

Comments
 (0)