From f61e15594b8911983dc6895955fe506f56b909a7 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 4 Feb 2022 16:17:36 +0000 Subject: [PATCH 1/2] Fix for #3928 - error invalid use of FETCH was based on a lack of sorting on MS-SQL platforms, this enforces a sort of some type no matter what. --- .../integrations/mssql/data/Dockerfile | 2 +- .../scripts/integrations/mssql/data/setup.sql | 21 +++++++++++++++---- packages/server/src/integrations/base/sql.ts | 14 ++++++------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/packages/server/scripts/integrations/mssql/data/Dockerfile b/packages/server/scripts/integrations/mssql/data/Dockerfile index 8ac56409a0..b8c96e8419 100644 --- a/packages/server/scripts/integrations/mssql/data/Dockerfile +++ b/packages/server/scripts/integrations/mssql/data/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/mssql/server +FROM mcr.microsoft.com/mssql/server:2017-latest ENV ACCEPT_EULA=Y ENV SA_PASSWORD=Passw0rd diff --git a/packages/server/scripts/integrations/mssql/data/setup.sql b/packages/server/scripts/integrations/mssql/data/setup.sql index 766388f46a..d0b4cfc39c 100644 --- a/packages/server/scripts/integrations/mssql/data/setup.sql +++ b/packages/server/scripts/integrations/mssql/data/setup.sql @@ -48,7 +48,20 @@ INSERT tasks VALUES ('Processing', 1); -INSERT people - (name, age) -VALUES - ('Bob', '30'); +INSERT INTO people (name, age) +VALUES ('Bob', '30'), + ('Bert', '10'), + ('Jack', '12'), + ('Mike', '31'), + ('Dave', '44'), + ('Jim', '43'), + ('Kerry', '32'), + ('Julie', '12'), + ('Kim', '55'), + ('Andy', '33'), + ('John', '22'), + ('Ruth', '66'), + ('Robert', '88'), + ('Bobert', '99'), + ('Jan', '22'), + ('Megan', '11'); diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index 2bcb5753d6..a4220565cf 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -166,15 +166,13 @@ class InternalBuilder { addSorting(query: KnexQuery, json: QueryJson): KnexQuery { let { sort, paginate } = json - if (!sort) { - return query - } const table = json.meta?.table - for (let [key, value] of Object.entries(sort)) { - const direction = value === SortDirection.ASCENDING ? "asc" : "desc" - query = query.orderBy(`${table?.name}.${key}`, direction) - } - if (this.client === SqlClients.MS_SQL && !sort && paginate?.limit) { + if (sort) { + for (let [key, value] of Object.entries(sort)) { + const direction = value === SortDirection.ASCENDING ? "asc" : "desc" + query = query.orderBy(`${table?.name}.${key}`, direction) + } + } else if (this.client === SqlClients.MS_SQL && paginate?.limit) { // @ts-ignore query = query.orderBy(`${table?.name}.${table?.primary[0]}`) } From e74621f327c17f1cef264363b58227b020482ede Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 4 Feb 2022 16:56:12 +0000 Subject: [PATCH 2/2] Fixing an issue with search field select erroring in builder when using queries in blocks. --- .../PropertiesPanel/PropertyControls/SearchFieldSelect.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte index 474fbc676c..e609426b1e 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/SearchFieldSelect.svelte @@ -25,7 +25,7 @@ return base } const currentTable = $tables.list.find(table => table._id === ds.tableId) - return getFields(base, { allowLinks: currentTable.sql }).map( + return getFields(base, { allowLinks: currentTable?.sql }).map( field => field.name ) }