diff --git a/packages/server/src/api/controllers/datasource.ts b/packages/server/src/api/controllers/datasource.ts index 9ae72ddf50..2d7ba8224f 100644 --- a/packages/server/src/api/controllers/datasource.ts +++ b/packages/server/src/api/controllers/datasource.ts @@ -21,7 +21,7 @@ import { CreateDatasourceRequest, VerifyDatasourceRequest, VerifyDatasourceResponse, - FetchTablesDatasourceResponse, + FetchDatasourceInfoResponse, IntegrationBase, DatasourcePlus, } from "@budibase/types" @@ -154,8 +154,8 @@ export async function verify( } } -export async function fetchTables( - ctx: UserCtx +export async function information( + ctx: UserCtx ) { const datasourceId = ctx.params.datasourceId const datasource = await sdk.datasources.get(datasourceId, { enriched: true }) diff --git a/packages/server/src/api/routes/datasource.ts b/packages/server/src/api/routes/datasource.ts index e740510d7f..ac8256539c 100644 --- a/packages/server/src/api/routes/datasource.ts +++ b/packages/server/src/api/routes/datasource.ts @@ -21,9 +21,9 @@ router datasourceController.verify ) .get( - "/api/datasources/:datasourceId/tables", + "/api/datasources/:datasourceId/info", authorized(permissions.BUILDER), - datasourceController.fetchTables + datasourceController.information ) .get( "/api/datasources/:datasourceId", diff --git a/packages/server/src/integration-test/postgres.spec.ts b/packages/server/src/integration-test/postgres.spec.ts index 0fd9b7c143..ce16ca4aba 100644 --- a/packages/server/src/integration-test/postgres.spec.ts +++ b/packages/server/src/integration-test/postgres.spec.ts @@ -1055,12 +1055,12 @@ describe("postgres integrations", () => { }) }) - describe("GET /api/datasources/:datasourceId/tables", () => { - it("should fetch tables within postgres datasource", async () => { + describe("GET /api/datasources/:datasourceId/info", () => { + it("should fetch information about postgres datasource", async () => { const primaryName = primaryPostgresTable.name const response = await makeRequest( "get", - `/api/datasources/${postgresDatasource._id}/tables` + `/api/datasources/${postgresDatasource._id}/info` ) expect(response.status).toBe(200) expect(response.body.tableNames).toBeDefined() diff --git a/packages/server/src/integrations/oracle.ts b/packages/server/src/integrations/oracle.ts index 55b425f480..afb7021a74 100644 --- a/packages/server/src/integrations/oracle.ts +++ b/packages/server/src/integrations/oracle.ts @@ -330,11 +330,7 @@ class OracleIntegration extends Sql implements DatasourcePlus { const columnsResponse = await this.internalQuery({ sql: this.COLUMNS_SQL, }) - if (!columnsResponse.rows) { - return [] - } else { - return columnsResponse.rows.map(row => row.TABLE_NAME) - } + return (columnsResponse.rows || []).map(row => row.TABLE_NAME) } async testConnection() { diff --git a/packages/types/src/api/web/app/datasource.ts b/packages/types/src/api/web/app/datasource.ts index 0d0406fe55..d15f65eb35 100644 --- a/packages/types/src/api/web/app/datasource.ts +++ b/packages/types/src/api/web/app/datasource.ts @@ -23,7 +23,7 @@ export interface VerifyDatasourceResponse { error?: string } -export interface FetchTablesDatasourceResponse { +export interface FetchDatasourceInfoResponse { tableNames: string[] }