Skip to content

Commit b27ab22

Browse files
committed
define types for TablesSchema query results
1 parent b6e6f84 commit b27ab22

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

packages/cubejs-base-driver/src/BaseDriver.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
TableMemoryData,
5353
PrimaryKeysQueryResult,
5454
ForeignKeysQueryResult,
55+
DatabaseStructure,
5556
} from './driver.interface';
5657

5758
/**
@@ -409,28 +410,28 @@ export abstract class BaseDriver implements DriverInterface {
409410
return false;
410411
}
411412

412-
protected informationColumnsSchemaReducer(result: any, i: any) {
413+
protected informationColumnsSchemaReducer(result: any, i: any): DatabaseStructure {
413414
let schema = (result[i.table_schema] || {});
414-
const tables = (schema[i.table_name] || []);
415+
const columns = (schema[i.table_name] || []);
415416

416-
tables.push({
417+
columns.push({
417418
name: i.column_name,
418419
type: i.data_type,
419420
attributes: i.key_type ? ['primaryKey'] : []
420421
});
421422

422-
tables.sort();
423-
schema[i.table_name] = tables;
423+
columns.sort();
424+
schema[i.table_name] = columns;
424425
schema = sortByKeys(schema);
425426
result[i.table_schema] = schema;
426427

427428
return sortByKeys(result);
428429
}
429430

430-
public tablesSchema(): Promise<any> {
431+
public tablesSchema(): Promise<DatabaseStructure> {
431432
const query = this.informationSchemaQuery();
432433

433-
return this.query(query, []).then(data => data.reduce(this.informationColumnsSchemaReducer, {}));
434+
return this.query(query, []).then(data => data.reduce<DatabaseStructure>(this.informationColumnsSchemaReducer, {}));
434435
}
435436

436437
// Extended version of tablesSchema containing primary and foreign keys

packages/cubejs-base-driver/src/driver.interface.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
export type GenericDataBaseType = string;
33

44
export interface TableColumn {
5-
// eslint-disable-next-line camelcase
65
name: string;
7-
// eslint-disable-next-line camelcase
86
type: GenericDataBaseType;
97
attributes?: string[]
108
}

0 commit comments

Comments
 (0)