Merge chore/remove-ds-query-api
This commit is contained in:
commit
2c8c80a086
|
@ -298,16 +298,6 @@ export async function find(ctx: UserCtx) {
|
|||
ctx.body = await sdk.datasources.removeSecretSingle(datasource)
|
||||
}
|
||||
|
||||
// dynamic query functionality
|
||||
export async function query(ctx: UserCtx<QueryJsonRequest>) {
|
||||
const queryJson = ctx.request.body
|
||||
try {
|
||||
ctx.body = await makeExternalQuery(queryJson)
|
||||
} catch (err: any) {
|
||||
ctx.throw(400, err)
|
||||
}
|
||||
}
|
||||
|
||||
export async function getExternalSchema(ctx: UserCtx) {
|
||||
const datasource = await sdk.datasources.get(ctx.params.datasourceId)
|
||||
const enrichedDatasource = await sdk.datasources.getAndMergeDatasource(
|
||||
|
|
|
@ -41,15 +41,6 @@ router
|
|||
),
|
||||
datasourceController.update
|
||||
)
|
||||
.post(
|
||||
"/api/datasources/query",
|
||||
authorized(
|
||||
permissions.PermissionType.TABLE,
|
||||
permissions.PermissionLevel.READ
|
||||
),
|
||||
datasourceQueryValidator(),
|
||||
datasourceController.query
|
||||
)
|
||||
.post(
|
||||
"/api/datasources/:datasourceId/schema",
|
||||
authorized(permissions.BUILDER),
|
||||
|
|
|
@ -817,49 +817,6 @@ if (descriptions.length) {
|
|||
})
|
||||
|
||||
describe("query through datasource", () => {
|
||||
it("should be able to query the datasource", async () => {
|
||||
const datasource = await config.api.datasource.create(rawDatasource)
|
||||
|
||||
const entityId = tableName
|
||||
await config.api.datasource.update({
|
||||
...datasource,
|
||||
entities: {
|
||||
[entityId]: {
|
||||
name: entityId,
|
||||
schema: {},
|
||||
type: "table",
|
||||
primary: ["id"],
|
||||
sourceId: datasource._id!,
|
||||
sourceType: TableSourceType.EXTERNAL,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const res = await config.api.datasource.query({
|
||||
endpoint: {
|
||||
datasourceId: datasource._id!,
|
||||
operation: Operation.READ,
|
||||
entityId,
|
||||
},
|
||||
resource: {
|
||||
fields: ["id", "name"],
|
||||
},
|
||||
filters: {
|
||||
string: {
|
||||
name: "two",
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(res).toHaveLength(1)
|
||||
expect(res[0]).toEqual({
|
||||
id: 2,
|
||||
name: "two",
|
||||
// the use of table.* introduces the possibility of nulls being returned
|
||||
birthday: null,
|
||||
number: null,
|
||||
})
|
||||
})
|
||||
|
||||
// this parameter really only impacts SQL queries
|
||||
describe("confirm nullDefaultSupport", () => {
|
||||
let queryParams: Partial<Query>
|
||||
|
|
|
@ -69,13 +69,6 @@ export class DatasourceAPI extends TestAPI {
|
|||
return await this._get<Datasource[]>(`/api/datasources`, { expectations })
|
||||
}
|
||||
|
||||
query = async (query: QueryJsonRequest, expectations?: Expectations) => {
|
||||
return await this._post<any>(`/api/datasources/query`, {
|
||||
body: query,
|
||||
expectations,
|
||||
})
|
||||
}
|
||||
|
||||
fetchSchema = async (
|
||||
{
|
||||
datasourceId,
|
||||
|
|
Loading…
Reference in New Issue