Follow-up PR to bigint fixes.

This commit is contained in:
Sam Rose 2024-11-28 16:17:09 +00:00
parent b17c6ab43a
commit f6ad53f442
No known key found for this signature in database
6 changed files with 27 additions and 22 deletions

View File

@ -23,13 +23,11 @@ import {
Table,
RowValue,
DynamicVariable,
QueryJsonRequest,
} from "@budibase/types"
import sdk from "../../sdk"
import { builderSocket } from "../../websockets"
import { isEqual } from "lodash"
import { processTable } from "../../sdk/app/tables/getters"
import { makeExternalQuery } from "../../integrations/base/query"
export async function fetch(ctx: UserCtx) {
ctx.body = await sdk.datasources.fetch()

View File

@ -1,27 +1,39 @@
import { DatasourcePlusQueryResponse, QueryJson } from "@budibase/types"
import {
DatasourcePlusQueryResponse,
EnrichedQueryJson,
QueryJson,
} from "@budibase/types"
import { getIntegration } from "../index"
import sdk from "../../sdk"
import { enrichQueryJson } from "../../sdk/app/rows/utils"
function isEnriched(
json: QueryJson | EnrichedQueryJson
): json is EnrichedQueryJson {
return "datasource" in json
}
export async function makeExternalQuery(
json: QueryJson
json: QueryJson | EnrichedQueryJson
): Promise<DatasourcePlusQueryResponse> {
const enrichedJson = await enrichQueryJson(json)
if (!enrichedJson.datasource) {
if (!isEnriched(json)) {
json = await enrichQueryJson(json)
if (json.datasource) {
json.datasource = await sdk.datasources.enrich(json.datasource)
}
}
if (!json.datasource) {
throw new Error("No datasource provided for external query")
}
enrichedJson.datasource = await sdk.datasources.enrich(
enrichedJson.datasource
)
const Integration = await getIntegration(enrichedJson.datasource.source)
const Integration = await getIntegration(json.datasource.source)
// query is the opinionated function
if (!Integration.prototype.query) {
throw "Datasource does not support query."
}
const integration = new Integration(enrichedJson.datasource.config)
return integration.query(enrichedJson)
const integration = new Integration(json.datasource.config)
return integration.query(json)
}

View File

@ -509,8 +509,8 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
async query(json: EnrichedQueryJson): Promise<DatasourcePlusQueryResponse> {
const schema = this.config.schema
await this.connect()
if (schema && schema !== DEFAULT_SCHEMA && json?.endpoint) {
json.endpoint.schema = schema
if (schema && schema !== DEFAULT_SCHEMA) {
json.schema = schema
}
const operation = this._operation(json)
const queryFn = (query: any, op: string) => this.internalQuery(query, op)

View File

@ -572,11 +572,7 @@ class OracleIntegration extends Sql implements DatasourcePlus {
return response.rows as Row[]
} else {
// get the last row that was updated
if (
response.lastRowid &&
json.endpoint?.entityId &&
operation !== Operation.DELETE
) {
if (response.lastRowid && operation !== Operation.DELETE) {
const lastRow = await this.internalQuery({
sql: `SELECT * FROM "${json.table.name}" WHERE ROWID = '${response.lastRowid}'`,
})

View File

@ -269,7 +269,7 @@ describe("Captures of real examples", () => {
fields: string[] = ["a"]
): EnrichedQueryJson {
return {
endpoint: { datasourceId: "", entityId: "", operation: op },
operation: op,
resource: {
fields,
},

View File

@ -4,7 +4,6 @@ import {
Datasource,
FetchDatasourceInfoResponse,
FieldType,
QueryJsonRequest,
RelationshipType,
UpdateDatasourceRequest,
UpdateDatasourceResponse,