PR comments.
This commit is contained in:
parent
7b603a35df
commit
590844c8a9
|
@ -21,7 +21,7 @@ import {
|
||||||
CreateDatasourceRequest,
|
CreateDatasourceRequest,
|
||||||
VerifyDatasourceRequest,
|
VerifyDatasourceRequest,
|
||||||
VerifyDatasourceResponse,
|
VerifyDatasourceResponse,
|
||||||
FetchTablesDatasourceResponse,
|
FetchDatasourceInfoResponse,
|
||||||
IntegrationBase,
|
IntegrationBase,
|
||||||
DatasourcePlus,
|
DatasourcePlus,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
@ -154,8 +154,8 @@ export async function verify(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchTables(
|
export async function information(
|
||||||
ctx: UserCtx<void, FetchTablesDatasourceResponse>
|
ctx: UserCtx<void, FetchDatasourceInfoResponse>
|
||||||
) {
|
) {
|
||||||
const datasourceId = ctx.params.datasourceId
|
const datasourceId = ctx.params.datasourceId
|
||||||
const datasource = await sdk.datasources.get(datasourceId, { enriched: true })
|
const datasource = await sdk.datasources.get(datasourceId, { enriched: true })
|
||||||
|
|
|
@ -21,9 +21,9 @@ router
|
||||||
datasourceController.verify
|
datasourceController.verify
|
||||||
)
|
)
|
||||||
.get(
|
.get(
|
||||||
"/api/datasources/:datasourceId/tables",
|
"/api/datasources/:datasourceId/info",
|
||||||
authorized(permissions.BUILDER),
|
authorized(permissions.BUILDER),
|
||||||
datasourceController.fetchTables
|
datasourceController.information
|
||||||
)
|
)
|
||||||
.get(
|
.get(
|
||||||
"/api/datasources/:datasourceId",
|
"/api/datasources/:datasourceId",
|
||||||
|
|
|
@ -1055,12 +1055,12 @@ describe("postgres integrations", () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("GET /api/datasources/:datasourceId/tables", () => {
|
describe("GET /api/datasources/:datasourceId/info", () => {
|
||||||
it("should fetch tables within postgres datasource", async () => {
|
it("should fetch information about postgres datasource", async () => {
|
||||||
const primaryName = primaryPostgresTable.name
|
const primaryName = primaryPostgresTable.name
|
||||||
const response = await makeRequest(
|
const response = await makeRequest(
|
||||||
"get",
|
"get",
|
||||||
`/api/datasources/${postgresDatasource._id}/tables`
|
`/api/datasources/${postgresDatasource._id}/info`
|
||||||
)
|
)
|
||||||
expect(response.status).toBe(200)
|
expect(response.status).toBe(200)
|
||||||
expect(response.body.tableNames).toBeDefined()
|
expect(response.body.tableNames).toBeDefined()
|
||||||
|
|
|
@ -330,11 +330,7 @@ class OracleIntegration extends Sql implements DatasourcePlus {
|
||||||
const columnsResponse = await this.internalQuery<OracleColumnsResponse>({
|
const columnsResponse = await this.internalQuery<OracleColumnsResponse>({
|
||||||
sql: this.COLUMNS_SQL,
|
sql: this.COLUMNS_SQL,
|
||||||
})
|
})
|
||||||
if (!columnsResponse.rows) {
|
return (columnsResponse.rows || []).map(row => row.TABLE_NAME)
|
||||||
return []
|
|
||||||
} else {
|
|
||||||
return columnsResponse.rows.map(row => row.TABLE_NAME)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async testConnection() {
|
async testConnection() {
|
||||||
|
|
|
@ -23,7 +23,7 @@ export interface VerifyDatasourceResponse {
|
||||||
error?: string
|
error?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FetchTablesDatasourceResponse {
|
export interface FetchDatasourceInfoResponse {
|
||||||
tableNames: string[]
|
tableNames: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue