From 3843dc994b2f50f347bfe1bb9c08ff0e03f4c0e4 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 26 Mar 2024 13:52:22 +0000 Subject: [PATCH] Fixing a type issue. --- .../server/src/sdk/app/rows/search/sqs.ts | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/server/src/sdk/app/rows/search/sqs.ts b/packages/server/src/sdk/app/rows/search/sqs.ts index 39204965f1..04ce2a51db 100644 --- a/packages/server/src/sdk/app/rows/search/sqs.ts +++ b/packages/server/src/sdk/app/rows/search/sqs.ts @@ -4,16 +4,19 @@ import { QueryJson, RelationshipFieldMetadata, Row, - SearchFilters, SearchParams, + SearchFilters, + SearchParams, + SortDirection, + SortOrder, SortType, Table, - SortJson, - SortOrder, - SortDirection, } from "@budibase/types" import SqlQueryBuilder from "../../../../integrations/base/sql" import { SqlClient } from "../../../../integrations/utils" -import { buildInternalRelationships, sqlOutputProcessing } from "../../../../api/controllers/row/utils" +import { + buildInternalRelationships, + sqlOutputProcessing, +} from "../../../../api/controllers/row/utils" import sdk from "../../../index" import { context } from "@budibase/backend-core" import { CONSTANT_INTERNAL_ROW_COLS } from "../../../../db/utils" @@ -128,17 +131,20 @@ export async function search(options: SearchParams) { if (params.sort && !params.sortType) { const sortField = table.schema[params.sort] - const sortType = sortField.type === FieldType.NUMBER ? SortType.NUMBER : SortType.STRING - const sortDirection = params.sortOrder === SortOrder.ASCENDING ? SortDirection.ASCENDING : SortDirection.DESCENDING - const sortObj: SortJson = { + const sortType = + sortField.type === FieldType.NUMBER ? SortType.NUMBER : SortType.STRING + const sortDirection = + params.sortOrder === SortOrder.ASCENDING + ? SortDirection.ASCENDING + : SortDirection.DESCENDING + request.sort = { [sortField.name]: { direction: sortDirection, type: sortType as SortType, }, } - request.sort = sortObj } - if (paginate) { + if (paginate && params.limit) { request.paginate = { limit: params.limit, page: params.bookmark,