diff --git a/packages/frontend-core/src/fetch/DataFetch.ts b/packages/frontend-core/src/fetch/DataFetch.ts index 74450c6254..9312c57637 100644 --- a/packages/frontend-core/src/fetch/DataFetch.ts +++ b/packages/frontend-core/src/fetch/DataFetch.ts @@ -11,7 +11,6 @@ import { SortType, TableSchema, UISearchFilter, - ViewSchema, } from "@budibase/types" import { APIClient } from "../api/types" @@ -224,12 +223,12 @@ export default abstract class DataFetch< supportsPagination: paginate && !!features?.supportsPagination, } - if (!definition?.schema) { + // Fetch and enrich schema + let schema = this.getSchema(definition) + if (!schema) { return } - - // Fetch and enrich schema - const schema = this.enrichSchema(definition.schema) + schema = this.enrichSchema(schema) // If an invalid sort column is specified, delete it if (this.options.sortColumn && !schema[this.options.sortColumn]) { @@ -362,9 +361,7 @@ export default abstract class DataFetch< * @param definition the datasource definition * @return {object} the schema */ - getSchema( - definition: TDefinition | null - ): ViewSchema | Record | undefined { + getSchema(definition: TDefinition | null): Record | undefined { return definition?.schema ?? undefined } @@ -379,7 +376,7 @@ export default abstract class DataFetch< let jsonAdditions: Record = {} for (const fieldKey of Object.keys(schema)) { const fieldSchema = schema[fieldKey] - if (fieldSchema?.type === FieldType.JSON) { + if (fieldSchema.type === FieldType.JSON) { const jsonSchema = convertJSONSchemaToTableSchema(fieldSchema, { squashObjects: true, }) as Record | null // TODO: remove when convertJSONSchemaToTableSchema is typed