Merge pull request #4019 from Budibase/fix/4010
Maintaining options and boolean types when fetching SQL schemas
This commit is contained in:
commit
8da0fa4124
|
@ -43,8 +43,8 @@ const coreFields = {
|
||||||
enum: Object.values(BodyTypes),
|
enum: Object.values(BodyTypes),
|
||||||
},
|
},
|
||||||
pagination: {
|
pagination: {
|
||||||
type: DatasourceFieldTypes.OBJECT
|
type: DatasourceFieldTypes.OBJECT,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
module RestModule {
|
module RestModule {
|
||||||
|
@ -178,12 +178,17 @@ module RestModule {
|
||||||
headers,
|
headers,
|
||||||
},
|
},
|
||||||
pagination: {
|
pagination: {
|
||||||
cursor: nextCursor
|
cursor: nextCursor,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getUrl(path: string, queryString: string, pagination: PaginationConfig | null, paginationValues: PaginationValues | null): string {
|
getUrl(
|
||||||
|
path: string,
|
||||||
|
queryString: string,
|
||||||
|
pagination: PaginationConfig | null,
|
||||||
|
paginationValues: PaginationValues | null
|
||||||
|
): string {
|
||||||
// Add pagination params to query string if required
|
// Add pagination params to query string if required
|
||||||
if (pagination?.location === "query" && paginationValues) {
|
if (pagination?.location === "query" && paginationValues) {
|
||||||
const { pageParam, sizeParam } = pagination
|
const { pageParam, sizeParam } = pagination
|
||||||
|
@ -217,14 +222,22 @@ module RestModule {
|
||||||
return complete
|
return complete
|
||||||
}
|
}
|
||||||
|
|
||||||
addBody(bodyType: string, body: string | any, input: any, pagination: PaginationConfig | null, paginationValues: PaginationValues | null) {
|
addBody(
|
||||||
|
bodyType: string,
|
||||||
|
body: string | any,
|
||||||
|
input: any,
|
||||||
|
pagination: PaginationConfig | null,
|
||||||
|
paginationValues: PaginationValues | null
|
||||||
|
) {
|
||||||
if (!input.headers) {
|
if (!input.headers) {
|
||||||
input.headers = {}
|
input.headers = {}
|
||||||
}
|
}
|
||||||
if (bodyType === BodyTypes.NONE) {
|
if (bodyType === BodyTypes.NONE) {
|
||||||
return input
|
return input
|
||||||
}
|
}
|
||||||
let error, object: any = {}, string = ""
|
let error,
|
||||||
|
object: any = {},
|
||||||
|
string = ""
|
||||||
try {
|
try {
|
||||||
if (body) {
|
if (body) {
|
||||||
string = typeof body !== "string" ? JSON.stringify(body) : body
|
string = typeof body !== "string" ? JSON.stringify(body) : body
|
||||||
|
@ -333,7 +346,7 @@ module RestModule {
|
||||||
requestBody,
|
requestBody,
|
||||||
authConfigId,
|
authConfigId,
|
||||||
pagination,
|
pagination,
|
||||||
paginationValues
|
paginationValues,
|
||||||
} = query
|
} = query
|
||||||
const authHeaders = this.getAuthHeaders(authConfigId)
|
const authHeaders = this.getAuthHeaders(authConfigId)
|
||||||
|
|
||||||
|
@ -352,7 +365,13 @@ module RestModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
let input: any = { method, headers: this.headers }
|
let input: any = { method, headers: this.headers }
|
||||||
input = this.addBody(bodyType, requestBody, input, pagination, paginationValues)
|
input = this.addBody(
|
||||||
|
bodyType,
|
||||||
|
requestBody,
|
||||||
|
input,
|
||||||
|
pagination,
|
||||||
|
paginationValues
|
||||||
|
)
|
||||||
|
|
||||||
this.startTimeMs = performance.now()
|
this.startTimeMs = performance.now()
|
||||||
const url = this.getUrl(path, queryString, pagination, paginationValues)
|
const url = this.getUrl(path, queryString, pagination, paginationValues)
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import { SqlQuery } from "../definitions/datasource"
|
import { SqlQuery } from "../definitions/datasource"
|
||||||
import { Datasource, Table } from "../definitions/common"
|
import { Datasource, Table } from "../definitions/common"
|
||||||
import { SourceNames } from "../definitions/datasource"
|
import { SourceNames } from "../definitions/datasource"
|
||||||
const { DocumentTypes, SEPARATOR } = require("../db/utils")
|
import { DocumentTypes, SEPARATOR } from "../db/utils"
|
||||||
const {
|
import { FieldTypes, BuildSchemaErrors, InvalidColumns } from "../constants"
|
||||||
FieldTypes,
|
|
||||||
BuildSchemaErrors,
|
|
||||||
InvalidColumns,
|
|
||||||
} = require("../constants")
|
|
||||||
|
|
||||||
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
|
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
|
||||||
const ROW_ID_REGEX = /^\[.*]$/g
|
const ROW_ID_REGEX = /^\[.*]$/g
|
||||||
|
@ -158,7 +154,12 @@ function copyExistingPropsOver(
|
||||||
if (!existingTableSchema.hasOwnProperty(key)) {
|
if (!existingTableSchema.hasOwnProperty(key)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (existingTableSchema[key].type === "link") {
|
if (
|
||||||
|
existingTableSchema[key].type === FieldTypes.LINK ||
|
||||||
|
existingTableSchema[key].type === FieldTypes.OPTIONS ||
|
||||||
|
((!table.schema[key] || table.schema[key].type === FieldTypes.NUMBER) &&
|
||||||
|
existingTableSchema[key].type === FieldTypes.BOOLEAN)
|
||||||
|
) {
|
||||||
table.schema[key] = existingTableSchema[key]
|
table.schema[key] = existingTableSchema[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue