Avoid displaying error message for @kind table queries

Also, add a unit test for this area.
This commit is contained in:
Andrew Eisenberg
2021-03-28 16:47:50 -07:00
parent 98a2bbbb47
commit 6d26491243
3 changed files with 30 additions and 3 deletions

View File

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

View File

@@ -174,7 +174,10 @@ export class QueryInfo {
if (!hasKind) {
logger.log('Cannot produce interpreted results since the query does not have @kind metadata.');
}
return hasMetadataFile && hasKind;
const isTable = hasKind && this.metadata?.kind === 'table';
return hasMetadataFile && hasKind && !isTable;
}
/**

View File

@@ -24,6 +24,23 @@ describe('run-queries', () => {
expect(info.dataset).to.eq('file:///abc');
});
it('should check if interpreted results can be created', async () => {
const info = createMockQueryInfo();
(info.dbItem.hasMetadataFile as sinon.SinonStub).returns(true);
expect(await info.canHaveInterpretedResults()).to.eq(true);
(info.dbItem.hasMetadataFile as sinon.SinonStub).returns(false);
expect(await info.canHaveInterpretedResults()).to.eq(false);
(info.dbItem.hasMetadataFile as sinon.SinonStub).returns(true);
info.metadata!.kind = undefined;
expect(await info.canHaveInterpretedResults()).to.eq(false);
info.metadata!.kind = 'table';
expect(await info.canHaveInterpretedResults()).to.eq(false);
});
describe('compile', () => {
it('should compile', async () => {
const info = createMockQueryInfo();
@@ -73,9 +90,14 @@ describe('run-queries', () => {
{
contents: {
datasetUri: 'file:///abc'
}
},
hasMetadataFile: sinon.stub()
} as unknown as DatabaseItem,
'my-scheme' // queryDbscheme
'my-scheme', // queryDbscheme,
undefined,
{
kind: 'problem'
}
);
}