Merge remote-tracking branch 'origin/main' into koesie10/compare-messages
This commit is contained in:
@@ -365,25 +365,34 @@ export interface SetComparisonQueryInfoMessage {
|
||||
export interface SetComparisonsMessage {
|
||||
readonly t: "setComparisons";
|
||||
readonly currentResultSetName: string;
|
||||
readonly result: RawQueryCompareResult | undefined;
|
||||
readonly result: QueryCompareResult | undefined;
|
||||
readonly message: string | undefined;
|
||||
}
|
||||
|
||||
type QueryCompareResult = RawQueryCompareResult | InterpretedQueryCompareResult;
|
||||
|
||||
/**
|
||||
* from is the set of rows that have changes in the "from" query.
|
||||
* to is the set of rows that have changes in the "to" query.
|
||||
* They are in the same order, so element 1 in "from" corresponds to
|
||||
* element 1 in "to".
|
||||
*
|
||||
* If an array element is null, that means that the element was removed
|
||||
* (or added) in the comparison.
|
||||
*/
|
||||
export type RawQueryCompareResult = {
|
||||
kind: "raw";
|
||||
columns: readonly BqrsColumn[];
|
||||
from: ResultRow[];
|
||||
to: ResultRow[];
|
||||
};
|
||||
|
||||
/**
|
||||
* from is the set of results that have changes in the "from" query.
|
||||
* to is the set of results that have changes in the "to" query.
|
||||
*/
|
||||
type InterpretedQueryCompareResult = {
|
||||
kind: "interpreted";
|
||||
sourceLocationPrefix: string;
|
||||
from: sarif.Result[];
|
||||
to: sarif.Result[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Extract the name of the default result. Prefer returning
|
||||
* 'alerts', or '#select'. Otherwise return the first in the list.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BQRSInfo } from "../common/bqrs-cli-types";
|
||||
import { getDefaultResultSetName } from "../common/interface-types";
|
||||
|
||||
export async function findCommonResultSetNames(
|
||||
fromSchemas: BQRSInfo,
|
||||
@@ -40,7 +41,8 @@ export async function findResultSetNames(
|
||||
);
|
||||
}
|
||||
|
||||
const currentResultSetName = selectedResultSetName || commonResultSetNames[0];
|
||||
const currentResultSetName =
|
||||
selectedResultSetName ?? getDefaultResultSetName(commonResultSetNames);
|
||||
const fromResultSetName = currentResultSetName || defaultFromResultSetName!;
|
||||
const toResultSetName = currentResultSetName || defaultToResultSetName!;
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ export default function resultsDiff(
|
||||
throw new Error("CodeQL Compare: Target query has no results.");
|
||||
}
|
||||
|
||||
const results = {
|
||||
const results: RawQueryCompareResult = {
|
||||
kind: "raw",
|
||||
columns: fromResults.columns,
|
||||
from: arrayDiff(fromResults.tuples, toResults.tuples),
|
||||
to: arrayDiff(toResults.tuples, fromResults.tuples),
|
||||
|
||||
@@ -38,6 +38,7 @@ CompareTable.args = {
|
||||
t: "setComparisons",
|
||||
currentResultSetName: "edges",
|
||||
result: {
|
||||
kind: "raw",
|
||||
columns: [
|
||||
{ name: "a", kind: "Entity" },
|
||||
{ name: "b", kind: "Entity" },
|
||||
|
||||
@@ -67,22 +67,26 @@ export default function CompareTable({ queryInfo, comparison }: Props) {
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<RawCompareResultTable
|
||||
columns={result.columns}
|
||||
schemaName={comparison.currentResultSetName}
|
||||
rows={result.from}
|
||||
databaseUri={queryInfo.databaseUri}
|
||||
className={className}
|
||||
/>
|
||||
{result.kind === "raw" && (
|
||||
<RawCompareResultTable
|
||||
columns={result.columns}
|
||||
schemaName={comparison.currentResultSetName}
|
||||
rows={result.from}
|
||||
databaseUri={queryInfo.databaseUri}
|
||||
className={className}
|
||||
/>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<RawCompareResultTable
|
||||
columns={result.columns}
|
||||
schemaName={comparison.currentResultSetName}
|
||||
rows={result.to}
|
||||
databaseUri={queryInfo.databaseUri}
|
||||
className={className}
|
||||
/>
|
||||
{result.kind === "raw" && (
|
||||
<RawCompareResultTable
|
||||
columns={result.columns}
|
||||
schemaName={comparison.currentResultSetName}
|
||||
rows={result.to}
|
||||
databaseUri={queryInfo.databaseUri}
|
||||
className={className}
|
||||
/>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user