From ece1c421fa616513f260382e3e7265f75a45e45a Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Fri, 4 Aug 2023 13:53:30 +0100 Subject: [PATCH 1/2] Fix/formula as display (#11439) * Allow formulas to be display columns in the grid * Ensure SQL Server always has a sort order --- .../components/grid/cells/HeaderCell.svelte | 1 - packages/server/src/integrations/base/sql.ts | 2 +- .../server/src/integrations/tests/sql.spec.ts | 21 +++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte b/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte index 8123871666..575a216c6f 100644 --- a/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte @@ -27,7 +27,6 @@ "array", "attachment", "boolean", - "formula", "json", ] diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index 90107dfd4e..2cdae682b0 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -315,7 +315,7 @@ class InternalBuilder { addSorting(query: KnexQuery, json: QueryJson): KnexQuery { let { sort, paginate } = json const table = json.meta?.table - if (sort) { + if (sort && Object.keys(sort || {}).length > 0) { for (let [key, value] of Object.entries(sort)) { const direction = value.direction === SortDirection.ASCENDING ? "asc" : "desc" diff --git a/packages/server/src/integrations/tests/sql.spec.ts b/packages/server/src/integrations/tests/sql.spec.ts index bd1497bdc7..0bf1498f5f 100644 --- a/packages/server/src/integrations/tests/sql.spec.ts +++ b/packages/server/src/integrations/tests/sql.spec.ts @@ -26,6 +26,12 @@ function generateReadJson({ filters: filters || {}, sort: sort || {}, paginate: paginate || {}, + meta: { + table: { + name: table || TABLE_NAME, + primary: ["id"], + }, + }, } } @@ -636,4 +642,19 @@ describe("SQL query builder", () => { sql: `select * from (select * from (select * from \"test\" where LOWER(\"test\".\"name\") LIKE :1) where rownum <= :2) \"test\"`, }) }) + + it("should sort SQL Server tables by the primary key if no sort data is provided", () => { + let query = new Sql(SqlClient.MS_SQL, limit)._query( + generateReadJson({ + sort: {}, + paginate: { + limit: 10, + }, + }) + ) + expect(query).toEqual({ + bindings: [10], + sql: `select * from (select top (@p0) * from [test] order by [test].[id] asc) as [test]`, + }) + }) }) From c29b48291398c3e8fd9edaad5e6a9a5e42e6bde0 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Fri, 4 Aug 2023 12:53:47 +0000 Subject: [PATCH 2/2] Bump version to 2.8.29-alpha.18 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index f33b6d0a7d..9ae6b7b4f8 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.8.29-alpha.17", + "version": "2.8.29-alpha.18", "npmClient": "yarn", "packages": [ "packages/*"