From 688a46f75ee14d05252c8aa26d8c6b6184801251 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 23 Jun 2022 13:09:22 +0100 Subject: [PATCH] Added Knex.Raw to return type --- packages/server/src/integrations/base/sql.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index c9841347a6..2758b6f1f1 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -89,7 +89,10 @@ function parseFilters(filters: SearchFilters | undefined): SearchFilters { return filters } -function generateSelectStatement(json: QueryJson, knex: Knex): any[] { +function generateSelectStatement( + json: QueryJson, + knex: Knex +): (string | Knex.Raw)[] { const { resource, meta } = json const schema = meta?.table?.schema return resource.fields.map(field => { @@ -235,9 +238,7 @@ class InternalBuilder { } addRelationships( - knex: Knex, query: KnexQuery, - fields: string | string[], fromTable: string, relationships: RelationshipsJson[] | undefined ): KnexQuery { @@ -342,7 +343,7 @@ class InternalBuilder { if (!resource) { resource = { fields: [] } } - let selectStatement: string | any[] = "*" + let selectStatement: string | (string | Knex.Raw)[] = "*" // handle select if (resource.fields && resource.fields.length > 0) { // select the resources as the format "table.columnName" - this is what is provided @@ -382,13 +383,7 @@ class InternalBuilder { preQuery = this.addSorting(preQuery, json) } // handle joins - query = this.addRelationships( - knex, - preQuery, - selectStatement, - tableName, - relationships - ) + query = this.addRelationships(preQuery, tableName, relationships) return this.addFilters(query, filters, { relationship: true }) }