1
0
Fork 0
mirror of synced 2024-07-07 07:15:43 +12:00

Addressing comment about datasource being optional.

This commit is contained in:
mike12345567 2024-06-19 12:03:20 +01:00
parent c973562398
commit abfab054d7
4 changed files with 10 additions and 8 deletions

View file

@ -33,5 +33,5 @@ export async function makeTableRequest(
if (renamed) {
json.meta!.renamed = renamed
}
return makeExternalQuery(json, datasource)
return makeExternalQuery(datasource, json)
}

View file

@ -8,8 +8,8 @@ import { getIntegration } from "../index"
import sdk from "../../sdk"
export async function makeExternalQuery(
json: QueryJson,
datasource?: Datasource
datasource: Datasource,
json: QueryJson
): Promise<DatasourcePlusQueryResponse> {
const entityId = json.endpoint.entityId,
tableName = json.meta.table.name,

View file

@ -11,10 +11,11 @@ import { SQS_DATASOURCE_INTERNAL } from "@budibase/backend-core"
import { getSQLClient } from "./utils"
import { cloneDeep } from "lodash"
import datasources from "../datasources"
import { BudibaseInternalDB } from "../../../db/utils"
type PerformQueryFunction = (
json: QueryJson,
datasource?: Datasource
datasource: Datasource,
json: QueryJson
) => Promise<DatasourcePlusQueryResponse>
const WRITE_OPERATIONS: Operation[] = [
@ -179,9 +180,10 @@ export default class AliasTables {
): Promise<DatasourcePlusQueryResponse> {
const datasourceId = json.endpoint.datasourceId
const isSqs = datasourceId === SQS_DATASOURCE_INTERNAL
let aliasingEnabled: boolean, datasource: Datasource | undefined
let aliasingEnabled: boolean, datasource: Datasource
if (isSqs) {
aliasingEnabled = this.isAliasingEnabled(json)
datasource = BudibaseInternalDB
} else {
datasource = await datasources.get(datasourceId)
aliasingEnabled = this.isAliasingEnabled(json, datasource)
@ -233,7 +235,7 @@ export default class AliasTables {
json.tableAliases = invertedTableAliases
}
let response: DatasourcePlusQueryResponse = await queryFn(json, datasource)
let response: DatasourcePlusQueryResponse = await queryFn(datasource, json)
if (Array.isArray(response) && aliasingEnabled) {
return this.reverse(response)
} else {

View file

@ -61,7 +61,7 @@ export async function getDatasourceAndQuery(
table,
}
}
return makeExternalQuery(json, datasource)
return makeExternalQuery(datasource, json)
}
export function cleanExportRows(