Skip to content

Commit b030df0

Browse files
committed
define types for TablesSchema query results
1 parent d2943e2 commit b030df0

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
/**
@@ -401,28 +402,28 @@ export abstract class BaseDriver implements DriverInterface {
401402
return false;
402403
}
403404

404-
protected informationColumnsSchemaReducer(result: any, i: any) {
405+
protected informationColumnsSchemaReducer(result: any, i: any): DatabaseStructure {
405406
let schema = (result[i.table_schema] || {});
406-
const tables = (schema[i.table_name] || []);
407+
const columns = (schema[i.table_name] || []);
407408

408-
tables.push({
409+
columns.push({
409410
name: i.column_name,
410411
type: i.data_type,
411412
attributes: i.key_type ? ['primaryKey'] : []
412413
});
413414

414-
tables.sort();
415-
schema[i.table_name] = tables;
415+
columns.sort();
416+
schema[i.table_name] = columns;
416417
schema = sortByKeys(schema);
417418
result[i.table_schema] = schema;
418419

419420
return sortByKeys(result);
420421
}
421422

422-
public tablesSchema(): Promise<any> {
423+
public tablesSchema(): Promise<DatabaseStructure> {
423424
const query = this.informationSchemaQuery();
424425

425-
return this.query(query, []).then(data => data.reduce(this.informationColumnsSchemaReducer, {}));
426+
return this.query(query, []).then(data => data.reduce<DatabaseStructure>(this.informationColumnsSchemaReducer, {}));
426427
}
427428

428429
// 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)