Skip to content

Commit 5c84467

Browse files
authored
feat(cubejs-server-core): add dbType to dataSources (#6089)
1 parent 23d7a90 commit 5c84467

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

packages/cubejs-api-gateway/test/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ describe('API Gateway', () => {
592592
}
593593
}]
594594
},
595-
{ route: 'data-sources', successResult: { dataSources: ['default'] } },
595+
{ route: 'data-sources', successResult: { dataSources: [{ dataSource: 'default', dbType: 'postgres' }] } },
596596
];
597597

598598
testConfigs.forEach((config) => {

packages/cubejs-api-gateway/test/mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export const compilerApi = jest.fn().mockImplementation(() => ({
143143

144144
async dataSources() {
145145
return {
146-
dataSources: ['default']
146+
dataSources: [{ dataSource: 'default', dbType: 'postgres' }]
147147
};
148148
},
149149
}));

packages/cubejs-server-core/src/core/CompilerApi.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ export class CompilerApi {
232232
dataSources.map(async (dataSource) => {
233233
try {
234234
await orchestratorApi.driverFactory(dataSource);
235-
return dataSource;
235+
const dbType = await this.getDbType(dataSource);
236+
return { dataSource, dbType };
236237
} catch (err) {
237238
return null;
238239
}

packages/cubejs-server-core/test/unit/index.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,11 @@ describe('index.test', () => {
414414
});
415415

416416
expect(dataSources).toHaveProperty('dataSources');
417-
expect(dataSources.dataSources).toEqual(['main']);
417+
expect(dataSources.dataSources).toEqual([{
418+
dataSource: 'main',
419+
dbType: 'mysql',
420+
}]);
421+
418422
expect(dataSourcesSpy).toHaveBeenCalled();
419423
dataSourcesSpy.mockClear();
420424
});

0 commit comments

Comments
 (0)