Move columns in compare view to result
The columns are part of the result, so they should be moved there. This is in preparation of showing SARIF results in the same view, which don't have columns.
This commit is contained in:
@@ -353,10 +353,9 @@ export interface SetComparisonsMessage {
|
|||||||
time: string;
|
time: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
readonly columns: readonly BqrsColumn[];
|
|
||||||
readonly commonResultSetNames: string[];
|
readonly commonResultSetNames: string[];
|
||||||
readonly currentResultSetName: string;
|
readonly currentResultSetName: string;
|
||||||
readonly rows: QueryCompareResult | undefined;
|
readonly result: RawQueryCompareResult | undefined;
|
||||||
readonly message: string | undefined;
|
readonly message: string | undefined;
|
||||||
readonly databaseUri: string;
|
readonly databaseUri: string;
|
||||||
}
|
}
|
||||||
@@ -370,7 +369,8 @@ export interface SetComparisonsMessage {
|
|||||||
* If an array element is null, that means that the element was removed
|
* If an array element is null, that means that the element was removed
|
||||||
* (or added) in the comparison.
|
* (or added) in the comparison.
|
||||||
*/
|
*/
|
||||||
export type QueryCompareResult = {
|
export type RawQueryCompareResult = {
|
||||||
|
columns: readonly BqrsColumn[];
|
||||||
from: ResultRow[];
|
from: ResultRow[];
|
||||||
to: ResultRow[];
|
to: ResultRow[];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ViewColumn } from "vscode";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
FromCompareViewMessage,
|
FromCompareViewMessage,
|
||||||
QueryCompareResult,
|
RawQueryCompareResult,
|
||||||
ToCompareViewMessage,
|
ToCompareViewMessage,
|
||||||
} from "../common/interface-types";
|
} from "../common/interface-types";
|
||||||
import { Logger, showAndLogExceptionWithTelemetry } from "../common/logging";
|
import { Logger, showAndLogExceptionWithTelemetry } from "../common/logging";
|
||||||
@@ -93,10 +93,10 @@ export class CompareView extends AbstractWebview<
|
|||||||
selectedResultSetName,
|
selectedResultSetName,
|
||||||
);
|
);
|
||||||
if (currentResultSetDisplayName) {
|
if (currentResultSetDisplayName) {
|
||||||
let rows: QueryCompareResult | undefined;
|
let result: RawQueryCompareResult | undefined;
|
||||||
let message: string | undefined;
|
let message: string | undefined;
|
||||||
try {
|
try {
|
||||||
rows = this.compareResults(fromResultSet, toResultSet);
|
result = this.compareResults(fromResultSet, toResultSet);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message = getErrorMessage(e);
|
message = getErrorMessage(e);
|
||||||
}
|
}
|
||||||
@@ -118,10 +118,9 @@ export class CompareView extends AbstractWebview<
|
|||||||
time: to.startTime,
|
time: to.startTime,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
columns: fromResultSet.columns,
|
result,
|
||||||
commonResultSetNames,
|
commonResultSetNames,
|
||||||
currentResultSetName: currentResultSetDisplayName,
|
currentResultSetName: currentResultSetDisplayName,
|
||||||
rows,
|
|
||||||
message,
|
message,
|
||||||
databaseUri: to.initialInfo.databaseInfo.databaseUri,
|
databaseUri: to.initialInfo.databaseInfo.databaseUri,
|
||||||
});
|
});
|
||||||
@@ -240,7 +239,7 @@ export class CompareView extends AbstractWebview<
|
|||||||
private compareResults(
|
private compareResults(
|
||||||
fromResults: DecodedBqrsChunk,
|
fromResults: DecodedBqrsChunk,
|
||||||
toResults: DecodedBqrsChunk,
|
toResults: DecodedBqrsChunk,
|
||||||
): QueryCompareResult {
|
): RawQueryCompareResult {
|
||||||
// Only compare columns that have the same name
|
// Only compare columns that have the same name
|
||||||
return resultsDiff(fromResults, toResults);
|
return resultsDiff(fromResults, toResults);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { DecodedBqrsChunk } from "../common/bqrs-cli-types";
|
import { DecodedBqrsChunk } from "../common/bqrs-cli-types";
|
||||||
import { QueryCompareResult } from "../common/interface-types";
|
import { RawQueryCompareResult } from "../common/interface-types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare the rows of two queries. Use deep equality to determine if
|
* Compare the rows of two queries. Use deep equality to determine if
|
||||||
@@ -22,7 +22,7 @@ import { QueryCompareResult } from "../common/interface-types";
|
|||||||
export default function resultsDiff(
|
export default function resultsDiff(
|
||||||
fromResults: DecodedBqrsChunk,
|
fromResults: DecodedBqrsChunk,
|
||||||
toResults: DecodedBqrsChunk,
|
toResults: DecodedBqrsChunk,
|
||||||
): QueryCompareResult {
|
): RawQueryCompareResult {
|
||||||
if (fromResults.columns.length !== toResults.columns.length) {
|
if (fromResults.columns.length !== toResults.columns.length) {
|
||||||
throw new Error("CodeQL Compare: Columns do not match.");
|
throw new Error("CodeQL Compare: Columns do not match.");
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,7 @@ export default function resultsDiff(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const results = {
|
const results = {
|
||||||
|
columns: fromResults.columns,
|
||||||
from: arrayDiff(fromResults.tuples, toResults.tuples),
|
from: arrayDiff(fromResults.tuples, toResults.tuples),
|
||||||
to: arrayDiff(toResults.tuples, fromResults.tuples),
|
to: arrayDiff(toResults.tuples, fromResults.tuples),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,13 +31,13 @@ CompareTable.args = {
|
|||||||
time: "8/16/2023, 3:07:21 PM",
|
time: "8/16/2023, 3:07:21 PM",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
columns: [
|
|
||||||
{ name: "a", kind: "Entity" },
|
|
||||||
{ name: "b", kind: "Entity" },
|
|
||||||
],
|
|
||||||
commonResultSetNames: ["edges", "nodes", "subpaths", "#select"],
|
commonResultSetNames: ["edges", "nodes", "subpaths", "#select"],
|
||||||
currentResultSetName: "edges",
|
currentResultSetName: "edges",
|
||||||
rows: {
|
result: {
|
||||||
|
columns: [
|
||||||
|
{ name: "a", kind: "Entity" },
|
||||||
|
{ name: "b", kind: "Entity" },
|
||||||
|
],
|
||||||
from: [],
|
from: [],
|
||||||
to: [
|
to: [
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ import "../results/resultsView.css";
|
|||||||
const emptyComparison: SetComparisonsMessage = {
|
const emptyComparison: SetComparisonsMessage = {
|
||||||
t: "setComparisons",
|
t: "setComparisons",
|
||||||
stats: {},
|
stats: {},
|
||||||
rows: undefined,
|
result: undefined,
|
||||||
columns: [],
|
|
||||||
commonResultSetNames: [],
|
commonResultSetNames: [],
|
||||||
currentResultSetName: "",
|
currentResultSetName: "",
|
||||||
databaseUri: "",
|
databaseUri: "",
|
||||||
@@ -28,8 +27,8 @@ export function Compare(_: Record<string, never>): JSX.Element {
|
|||||||
|
|
||||||
const message = comparison.message || "Empty comparison";
|
const message = comparison.message || "Empty comparison";
|
||||||
const hasRows =
|
const hasRows =
|
||||||
comparison.rows &&
|
comparison.result &&
|
||||||
(comparison.rows.to.length || comparison.rows.from.length);
|
(comparison.result.to.length || comparison.result.from.length);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const listener = (evt: MessageEvent) => {
|
const listener = (evt: MessageEvent) => {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const OpenButton = styled(TextButton)`
|
|||||||
|
|
||||||
export default function CompareTable(props: Props) {
|
export default function CompareTable(props: Props) {
|
||||||
const comparison = props.comparison;
|
const comparison = props.comparison;
|
||||||
const rows = props.comparison.rows!;
|
const result = props.comparison.result!;
|
||||||
|
|
||||||
async function openQuery(kind: "from" | "to") {
|
async function openQuery(kind: "from" | "to") {
|
||||||
vscode.postMessage({
|
vscode.postMessage({
|
||||||
@@ -69,8 +69,8 @@ export default function CompareTable(props: Props) {
|
|||||||
<td>{comparison.stats.toQuery?.time}</td>
|
<td>{comparison.stats.toQuery?.time}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{rows.from.length} rows removed</th>
|
<th>{result.from.length} rows removed</th>
|
||||||
<th>{rows.to.length} rows added</th>
|
<th>{result.to.length} rows added</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -78,21 +78,21 @@ export default function CompareTable(props: Props) {
|
|||||||
<td>
|
<td>
|
||||||
<table className={className}>
|
<table className={className}>
|
||||||
<RawTableHeader
|
<RawTableHeader
|
||||||
columns={comparison.columns}
|
columns={result.columns}
|
||||||
schemaName={comparison.currentResultSetName}
|
schemaName={comparison.currentResultSetName}
|
||||||
preventSort={true}
|
preventSort={true}
|
||||||
/>
|
/>
|
||||||
{createRows(rows.from, comparison.databaseUri)}
|
{createRows(result.from, comparison.databaseUri)}
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<table className={className}>
|
<table className={className}>
|
||||||
<RawTableHeader
|
<RawTableHeader
|
||||||
columns={comparison.columns}
|
columns={result.columns}
|
||||||
schemaName={comparison.currentResultSetName}
|
schemaName={comparison.currentResultSetName}
|
||||||
preventSort={true}
|
preventSort={true}
|
||||||
/>
|
/>
|
||||||
{createRows(rows.to, comparison.databaseUri)}
|
{createRows(result.to, comparison.databaseUri)}
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user