Merge pull request #3111 from github/koesie10/compare-raw
Add interpreted results type to compare view
This commit is contained in:
@@ -355,26 +355,35 @@ export interface SetComparisonsMessage {
|
|||||||
};
|
};
|
||||||
readonly commonResultSetNames: string[];
|
readonly commonResultSetNames: string[];
|
||||||
readonly currentResultSetName: string;
|
readonly currentResultSetName: string;
|
||||||
readonly result: RawQueryCompareResult | undefined;
|
readonly result: QueryCompareResult | undefined;
|
||||||
readonly message: string | undefined;
|
readonly message: string | undefined;
|
||||||
readonly databaseUri: string;
|
readonly databaseUri: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type QueryCompareResult = RawQueryCompareResult | InterpretedQueryCompareResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* from is the set of rows that have changes in the "from" query.
|
* 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.
|
* 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 = {
|
export type RawQueryCompareResult = {
|
||||||
|
kind: "raw";
|
||||||
columns: readonly BqrsColumn[];
|
columns: readonly BqrsColumn[];
|
||||||
from: ResultRow[];
|
from: ResultRow[];
|
||||||
to: 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
|
* Extract the name of the default result. Prefer returning
|
||||||
* 'alerts', or '#select'. Otherwise return the first in the list.
|
* 'alerts', or '#select'. Otherwise return the first in the list.
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ export default function resultsDiff(
|
|||||||
throw new Error("CodeQL Compare: Target query has no results.");
|
throw new Error("CodeQL Compare: Target query has no results.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const results = {
|
const results: RawQueryCompareResult = {
|
||||||
|
kind: "raw",
|
||||||
columns: fromResults.columns,
|
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),
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ CompareTable.args = {
|
|||||||
commonResultSetNames: ["edges", "nodes", "subpaths", "#select"],
|
commonResultSetNames: ["edges", "nodes", "subpaths", "#select"],
|
||||||
currentResultSetName: "edges",
|
currentResultSetName: "edges",
|
||||||
result: {
|
result: {
|
||||||
|
kind: "raw",
|
||||||
columns: [
|
columns: [
|
||||||
{ name: "a", kind: "Entity" },
|
{ name: "a", kind: "Entity" },
|
||||||
{ name: "b", kind: "Entity" },
|
{ name: "b", kind: "Entity" },
|
||||||
|
|||||||
@@ -64,22 +64,26 @@ export default function CompareTable(props: Props) {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<RawCompareResultTable
|
{result.kind === "raw" && (
|
||||||
columns={result.columns}
|
<RawCompareResultTable
|
||||||
schemaName={comparison.currentResultSetName}
|
columns={result.columns}
|
||||||
rows={result.from}
|
schemaName={comparison.currentResultSetName}
|
||||||
databaseUri={comparison.databaseUri}
|
rows={result.from}
|
||||||
className={className}
|
databaseUri={comparison.databaseUri}
|
||||||
/>
|
className={className}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<RawCompareResultTable
|
{result.kind === "raw" && (
|
||||||
columns={result.columns}
|
<RawCompareResultTable
|
||||||
schemaName={comparison.currentResultSetName}
|
columns={result.columns}
|
||||||
rows={result.to}
|
schemaName={comparison.currentResultSetName}
|
||||||
databaseUri={comparison.databaseUri}
|
rows={result.to}
|
||||||
className={className}
|
databaseUri={comparison.databaseUri}
|
||||||
/>
|
className={className}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user