Skip to content

Commit 1d14ca1

Browse files
committed
Avoid displaying error message for @kind table queries
Also, add a unit test for this area.
1 parent 98a2bbb commit 1d14ca1

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [UNRELEASED]
44

5+
- Avoid showing an error popup when user runs a query with `@kind table` metadata. [#814](https://github.com/github/vscode-codeql/pull/814)
6+
57
## 1.4.5 - 22 March 2021
68

79
- Avoid showing an error popup when user runs a query without `@kind` metadata. [#801](https://github.com/github/vscode-codeql/pull/801)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ export class QueryInfo {
174174
if (!hasKind) {
175175
logger.log('Cannot produce interpreted results since the query does not have @kind metadata.');
176176
}
177-
return hasMetadataFile && hasKind;
177+
178+
const isTable = hasKind && this.metadata?.kind === 'table';
179+
180+
return hasMetadataFile && hasKind && !isTable;
178181
}
179182

180183
/**

extensions/ql-vscode/src/vscode-tests/no-workspace/run-queries.test.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ describe('run-queries', () => {
2424
expect(info.dataset).to.eq('file:///abc');
2525
});
2626

27+
it('should check if interpreted results can be created', async () => {
28+
const info = createMockQueryInfo();
29+
(info.dbItem.hasMetadataFile as sinon.SinonStub).returns(true);
30+
31+
expect(await info.canHaveInterpretedResults()).to.eq(true);
32+
33+
(info.dbItem.hasMetadataFile as sinon.SinonStub).returns(false);
34+
expect(await info.canHaveInterpretedResults()).to.eq(false);
35+
36+
(info.dbItem.hasMetadataFile as sinon.SinonStub).returns(true);
37+
info.metadata!.kind = undefined;
38+
expect(await info.canHaveInterpretedResults()).to.eq(false);
39+
40+
info.metadata!.kind = 'table';
41+
expect(await info.canHaveInterpretedResults()).to.eq(false);
42+
});
43+
2744
describe('compile', () => {
2845
it('should compile', async () => {
2946
const info = createMockQueryInfo();
@@ -73,9 +90,14 @@ describe('run-queries', () => {
7390
{
7491
contents: {
7592
datasetUri: 'file:///abc'
76-
}
93+
},
94+
hasMetadataFile: sinon.stub()
7795
} as unknown as DatabaseItem,
78-
'my-scheme' // queryDbscheme
96+
'my-scheme', // queryDbscheme,
97+
undefined,
98+
{
99+
kind: 'problem'
100+
}
79101
);
80102
}
81103

0 commit comments

Comments
 (0)