From 2cdc2f3fec786e308fbe4049cecff0ef0a518f9a Mon Sep 17 00:00:00 2001 From: adrinr Date: Tue, 7 Feb 2023 12:29:58 +0000 Subject: [PATCH] Fix select statement when no resource --- packages/server/src/integrations/base/sql.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index 2599f1ca0d..e42350091b 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -90,10 +90,15 @@ function parseFilters(filters: SearchFilters | undefined): SearchFilters { function generateSelectStatement( json: QueryJson, knex: Knex -): (string | Knex.Raw)[] { +): (string | Knex.Raw)[] | "*" { const { resource, meta } = json + + if (!resource) { + return "*" + } + const schema = meta?.table?.schema - return resource!.fields.map(field => { + return resource.fields.map(field => { const fieldNames = field.split(/\./g) const tableName = fieldNames[0] const columnName = fieldNames[1]