PR comments.

This commit is contained in:
mike12345567 2023-05-23 12:22:22 +01:00
parent 7b603a35df
commit 590844c8a9
5 changed files with 10 additions and 14 deletions

View File

@ -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<void, FetchTablesDatasourceResponse>
export async function information(
ctx: UserCtx<void, FetchDatasourceInfoResponse>
) {
const datasourceId = ctx.params.datasourceId
const datasource = await sdk.datasources.get(datasourceId, { enriched: true })

View File

@ -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",

View File

@ -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()

View File

@ -330,11 +330,7 @@ class OracleIntegration extends Sql implements DatasourcePlus {
const columnsResponse = await this.internalQuery<OracleColumnsResponse>({
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() {

View File

@ -23,7 +23,7 @@ export interface VerifyDatasourceResponse {
error?: string
}
export interface FetchTablesDatasourceResponse {
export interface FetchDatasourceInfoResponse {
tableNames: string[]
}