Skip to content

Commit 28be984

Browse files
committed
Add constants for bqrs column kinds
1 parent 5592a77 commit 28be984

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

extensions/ql-vscode/src/bqrs-cli-types.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11

22
export const PAGE_SIZE = 1000;
33

4-
export type ColumnKind = "f" | "i" | "s" | "b" | "d" | "e";
4+
/**
5+
* The single-character codes used in the bqrs format for the the kind
6+
* of a result column. This namespace is intentionally not an enum, see
7+
* the "for the sake of extensibility" comment in messages.ts.
8+
*/
9+
export namespace ColumnKindCode {
10+
export const FLOAT = "f";
11+
export const INTEGER = "i";
12+
export const STRING = "s";
13+
export const BOOLEAN = "b";
14+
export const DATE = "d";
15+
export const ENTITY = "e";
16+
}
17+
18+
export type ColumnKind =
19+
| typeof ColumnKindCode.FLOAT
20+
| typeof ColumnKindCode.INTEGER
21+
| typeof ColumnKindCode.STRING
22+
| typeof ColumnKindCode.BOOLEAN
23+
| typeof ColumnKindCode.DATE
24+
| typeof ColumnKindCode.ENTITY;
525

626
export interface Column {
727
name?: string;
828
kind: ColumnKind;
929
}
1030

11-
1231
export interface ResultSetSchema {
1332
name: string;
1433
rows: number;

extensions/ql-vscode/src/definitions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as yaml from 'js-yaml';
33
import * as tmp from 'tmp';
44
import * as vscode from "vscode";
55
import { decodeSourceArchiveUri, zipArchiveScheme } from "./archive-filesystem-provider";
6-
import { EntityValue, getResultSetSchema, LineColumnLocation, UrlValue } from "./bqrs-cli-types";
6+
import { EntityValue, getResultSetSchema, LineColumnLocation, UrlValue, ColumnKindCode } from "./bqrs-cli-types";
77
import { CodeQLCliServer } from "./cli";
88
import { DatabaseItem, DatabaseManager } from "./databases";
99
import * as helpers from './helpers';
@@ -156,9 +156,9 @@ async function getLinksFromResults(results: QueryWithResults, cli: CodeQLCliServ
156156
const info = await cli.bqrsInfo(bqrsPath);
157157
const selectInfo = getResultSetSchema(SELECT_QUERY_NAME, info);
158158
if (selectInfo && selectInfo.columns.length == 3
159-
&& selectInfo.columns[0].kind == "e"
160-
&& selectInfo.columns[1].kind == "e"
161-
&& selectInfo.columns[2].kind == "s") {
159+
&& selectInfo.columns[0].kind == ColumnKindCode.ENTITY
160+
&& selectInfo.columns[1].kind == ColumnKindCode.ENTITY
161+
&& selectInfo.columns[2].kind == ColumnKindCode.STRING) {
162162
// TODO: Page this
163163
const allTuples = await cli.bqrsDecode(bqrsPath, SELECT_QUERY_NAME);
164164
for (const tuple of allTuples.tuples) {

0 commit comments

Comments
 (0)