Fixing an issue with default parameters not being passed into dynamic parameters.
This commit is contained in:
parent
9912904bd1
commit
4a1f24d0d8
|
@ -14,7 +14,13 @@ import { context, cache, auth } from "@budibase/backend-core"
|
|||
import { getGlobalIDFromUserMetadataID } from "../db/utils"
|
||||
import sdk from "../sdk"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
import { Datasource, Query, SourceName, Row } from "@budibase/types"
|
||||
import {
|
||||
Datasource,
|
||||
Query,
|
||||
SourceName,
|
||||
Row,
|
||||
QueryParameter,
|
||||
} from "@budibase/types"
|
||||
|
||||
import { isSQL } from "../integrations/utils"
|
||||
import { interpolateSQL } from "../integrations/queries/sql"
|
||||
|
@ -196,12 +202,22 @@ class QueryRunner {
|
|||
return { rows, keys, info, extra, pagination }
|
||||
}
|
||||
|
||||
async runAnotherQuery(queryId: string, parameters: any) {
|
||||
async runAnotherQuery(
|
||||
queryId: string,
|
||||
currentParameters: Record<string, any>
|
||||
) {
|
||||
const db = context.getAppDB()
|
||||
const query = await db.get<Query>(queryId)
|
||||
const datasource = await sdk.datasources.get(query.datasourceId, {
|
||||
enriched: true,
|
||||
})
|
||||
// enrich parameters with dynamic queries defaults
|
||||
const defaultParams = query.parameters || []
|
||||
for (let param of defaultParams) {
|
||||
if (!currentParameters[param.name]) {
|
||||
currentParameters[param.name] = param.default
|
||||
}
|
||||
}
|
||||
return new QueryRunner(
|
||||
{
|
||||
schema: query.schema,
|
||||
|
@ -210,7 +226,7 @@ class QueryRunner {
|
|||
transformer: query.transformer,
|
||||
nullDefaultSupport: query.nullDefaultSupport,
|
||||
ctx: this.ctx,
|
||||
parameters,
|
||||
parameters: currentParameters,
|
||||
datasource,
|
||||
queryId,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue