From 95e0c1aa1f743ecd1d5ae866d7ea29ca14fa09d5 Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Tue, 25 Jan 2022 21:35:11 +0000 Subject: [PATCH 1/5] Adding a possible fix for #4179. --- packages/server/src/api/controllers/row/ExternalRequest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index af199561dc..0bffd134c1 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -525,7 +525,7 @@ module External { const linkTable = this.getTable(tableId) // @ts-ignore const linkPrimary = linkTable.primary[0] - const rows = related[key].rows || [] + const rows = related[key]?.rows || [] const found = rows.find( (row: { [key: string]: any }) => row[linkPrimary] === relationship.id || From 9b55ba8b13cbe18e29818dc1731182e11a9710b4 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 26 Jan 2022 18:50:13 +0000 Subject: [PATCH 2/5] Fixing #4192 - allowing switching between JSON and multi-select types, as well as not switching multi-select to JSON when fetching SQL tables. --- .../DataTable/modals/CreateEditColumn.svelte | 7 ++++++ .../builder/src/constants/backend/index.js | 13 ++++++---- .../server/src/api/controllers/table/utils.js | 25 +++++++++++++++++-- packages/server/src/constants/index.js | 13 ++++++---- packages/server/src/integrations/utils.ts | 1 + 5 files changed, 47 insertions(+), 12 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 752f291019..d8958b2361 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -22,8 +22,10 @@ RelationshipTypes, ALLOWABLE_STRING_OPTIONS, ALLOWABLE_NUMBER_OPTIONS, + ALLOWABLE_JSON_OPTIONS, ALLOWABLE_STRING_TYPES, ALLOWABLE_NUMBER_TYPES, + ALLOWABLE_JSON_TYPES, SWITCHABLE_TYPES, } from "constants/backend" import { getAutoColumnInformation, buildAutoColumn } from "builderStore/utils" @@ -236,6 +238,11 @@ ALLOWABLE_NUMBER_TYPES.indexOf(field.type) !== -1 ) { return ALLOWABLE_NUMBER_OPTIONS + } else if ( + originalName && + ALLOWABLE_JSON_TYPES.indexOf(field.type) !== -1 + ) { + return ALLOWABLE_JSON_OPTIONS } else if (!external) { return [ ...Object.values(fieldDefinitions), diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index c5fb294f80..ddff3b1f13 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -148,20 +148,23 @@ export const RelationshipTypes = { } export const ALLOWABLE_STRING_OPTIONS = [FIELDS.STRING, FIELDS.OPTIONS] - export const ALLOWABLE_STRING_TYPES = ALLOWABLE_STRING_OPTIONS.map( opt => opt.type ) export const ALLOWABLE_NUMBER_OPTIONS = [FIELDS.NUMBER, FIELDS.BOOLEAN] - export const ALLOWABLE_NUMBER_TYPES = ALLOWABLE_NUMBER_OPTIONS.map( opt => opt.type ) -export const SWITCHABLE_TYPES = ALLOWABLE_NUMBER_TYPES.concat( - ALLOWABLE_STRING_TYPES -) +export const ALLOWABLE_JSON_OPTIONS = [FIELDS.JSON, FIELDS.ARRAY] +export const ALLOWABLE_JSON_TYPES = ALLOWABLE_JSON_OPTIONS.map(opt => opt.type) + +export const SWITCHABLE_TYPES = [ + ...ALLOWABLE_STRING_TYPES, + ...ALLOWABLE_NUMBER_TYPES, + ...ALLOWABLE_JSON_TYPES, +] export const IntegrationTypes = { POSTGRES: "POSTGRES", diff --git a/packages/server/src/api/controllers/table/utils.js b/packages/server/src/api/controllers/table/utils.js index e4086e8071..754b0af5b3 100644 --- a/packages/server/src/api/controllers/table/utils.js +++ b/packages/server/src/api/controllers/table/utils.js @@ -8,7 +8,11 @@ const { const { isEqual } = require("lodash/fp") const { AutoFieldSubTypes, FieldTypes } = require("../../../constants") const { inputProcessing } = require("../../../utilities/rowProcessor") -const { USERS_TABLE_SCHEMA, SwitchableTypes } = require("../../../constants") +const { + USERS_TABLE_SCHEMA, + SwitchableTypes, + CanSwitchTypes, +} = require("../../../constants") const { isExternalTable, breakExternalTableId, @@ -340,6 +344,23 @@ exports.foreignKeyStructure = (keyName, meta = null) => { return structure } +exports.areSwitchableTypes = (type1, type2) => { + if ( + SwitchableTypes.indexOf(type1) === -1 && + SwitchableTypes.indexOf(type2) === -1 + ) { + return false + } + for (let option of CanSwitchTypes) { + const index1 = option.indexOf(type1), + index2 = option.indexOf(type2) + if (index1 !== -1 && index2 !== -1 && index1 !== index2) { + return true + } + } + return false +} + exports.hasTypeChanged = (table, oldTable) => { if (!oldTable) { return false @@ -350,7 +371,7 @@ exports.hasTypeChanged = (table, oldTable) => { continue } const newType = table.schema[key].type - if (oldType !== newType && SwitchableTypes.indexOf(oldType) === -1) { + if (oldType !== newType && !exports.areSwitchableTypes(oldType, newType)) { return true } } diff --git a/packages/server/src/constants/index.js b/packages/server/src/constants/index.js index b63b71d2c2..9743ddfab3 100644 --- a/packages/server/src/constants/index.js +++ b/packages/server/src/constants/index.js @@ -45,13 +45,16 @@ exports.FieldTypes = { INTERNAL: "internal", } -exports.SwitchableTypes = [ - exports.FieldTypes.STRING, - exports.FieldTypes.OPTIONS, - exports.FieldTypes.NUMBER, - exports.FieldTypes.BOOLEAN, +exports.CanSwitchTypes = [ + [exports.FieldTypes.JSON, exports.FieldTypes.ARRAY], + [exports.FieldTypes.STRING, exports.FieldTypes.OPTIONS], + [exports.FieldTypes.BOOLEAN, exports.FieldTypes.NUMBER], ] +exports.SwitchableTypes = exports.CanSwitchTypes.reduce((prev, current) => + prev ? prev.concat(current) : current +) + exports.RelationshipTypes = { ONE_TO_MANY: "one-to-many", MANY_TO_ONE: "many-to-one", diff --git a/packages/server/src/integrations/utils.ts b/packages/server/src/integrations/utils.ts index b1e42a51b3..b243e5e8ba 100644 --- a/packages/server/src/integrations/utils.ts +++ b/packages/server/src/integrations/utils.ts @@ -157,6 +157,7 @@ function copyExistingPropsOver( if ( existingTableSchema[key].type === FieldTypes.LINK || existingTableSchema[key].type === FieldTypes.OPTIONS || + existingTableSchema[key].type === FieldTypes.ARRAY || ((!table.schema[key] || table.schema[key].type === FieldTypes.NUMBER) && existingTableSchema[key].type === FieldTypes.BOOLEAN) ) { From 412b7e5f06b43b0d629e4473fb7440d82ff53c2d Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 26 Jan 2022 18:59:41 +0000 Subject: [PATCH 3/5] Fixing #4205 - making sure builder loads the correct role for the query. --- .../integration/AccessLevelSelect.svelte | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/builder/src/components/integration/AccessLevelSelect.svelte b/packages/builder/src/components/integration/AccessLevelSelect.svelte index 88814ed648..97587c287a 100644 --- a/packages/builder/src/components/integration/AccessLevelSelect.svelte +++ b/packages/builder/src/components/integration/AccessLevelSelect.svelte @@ -1,16 +1,14 @@ {#if loaded} From 86ffa65d938d80133038b85346f209d0e2fc5084 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 31 Jan 2022 13:43:13 +0000 Subject: [PATCH 4/5] v1.0.48 --- lerna.json | 2 +- packages/backend-core/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 6 +++--- packages/server/package.json | 8 ++++---- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lerna.json b/lerna.json index 7899c71f2d..801ba1b871 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.47", + "version": "1.0.48", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index ef49cd6307..f1998660a8 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.0.47", + "version": "1.0.48", "description": "Budibase backend core libraries used in server and worker", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 04a8d2e522..d9192c8b71 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.47", + "version": "1.0.48", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 1d4e37c665..f956a22027 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.47", + "version": "1.0.48", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.47", - "@budibase/client": "^1.0.47", + "@budibase/bbui": "^1.0.48", + "@budibase/client": "^1.0.48", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^1.0.47", + "@budibase/string-templates": "^1.0.48", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index b101ff94a1..016de84bef 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.47", + "version": "1.0.48", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index a8000503af..4cdbd22f18 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.47", + "version": "1.0.48", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^1.0.47", + "@budibase/bbui": "^1.0.48", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^1.0.47", + "@budibase/string-templates": "^1.0.48", "regexparam": "^1.3.0", "shortid": "^2.2.15", "svelte-spa-router": "^3.0.5" diff --git a/packages/server/package.json b/packages/server/package.json index 477c45fc4a..16a3a6803f 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.0.47", + "version": "1.0.48", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -70,9 +70,9 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "^10.0.3", - "@budibase/backend-core": "^1.0.47", - "@budibase/client": "^1.0.47", - "@budibase/string-templates": "^1.0.47", + "@budibase/backend-core": "^1.0.48", + "@budibase/client": "^1.0.48", + "@budibase/string-templates": "^1.0.48", "@bull-board/api": "^3.7.0", "@bull-board/koa": "^3.7.0", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 69e91740a2..69c7ae8f83 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.47", + "version": "1.0.48", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index 1cbc0cb246..f263f50a27 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.0.47", + "version": "1.0.48", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -29,8 +29,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.0.47", - "@budibase/string-templates": "^1.0.47", + "@budibase/backend-core": "^1.0.48", + "@budibase/string-templates": "^1.0.48", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0", From 4b9acb21ae2b0c4b1273bea29d30ed6d39919da7 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 31 Jan 2022 14:39:05 +0000 Subject: [PATCH 5/5] v1.0.49-alpha.0 --- lerna.json | 2 +- packages/backend-core/package.json | 2 +- packages/bbui/package.json | 2 +- packages/builder/package.json | 8 ++++---- packages/cli/package.json | 2 +- packages/client/package.json | 6 +++--- packages/server/package.json | 8 ++++---- packages/string-templates/package.json | 2 +- packages/worker/package.json | 6 +++--- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lerna.json b/lerna.json index 801ba1b871..2d503eaf59 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.48", + "version": "1.0.49-alpha.0", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index f1998660a8..18a6281aa0 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.0.48", + "version": "1.0.49-alpha.0", "description": "Budibase backend core libraries used in server and worker", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index d9192c8b71..d7757d6181 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.0.48", + "version": "1.0.49-alpha.0", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index f956a22027..3982c0965d 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.48", + "version": "1.0.49-alpha.0", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.48", - "@budibase/client": "^1.0.48", + "@budibase/bbui": "^1.0.49-alpha.0", + "@budibase/client": "^1.0.49-alpha.0", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^1.0.48", + "@budibase/string-templates": "^1.0.49-alpha.0", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 016de84bef..7e07be16b6 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.48", + "version": "1.0.49-alpha.0", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { diff --git a/packages/client/package.json b/packages/client/package.json index 6b9aa18a2b..bcb3a870ed 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.48", + "version": "1.0.49-alpha.0", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^1.0.48", + "@budibase/bbui": "^1.0.49-alpha.0", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^1.0.48", + "@budibase/string-templates": "^1.0.49-alpha.0", "regexparam": "^1.3.0", "rollup-plugin-polyfill-node": "^0.8.0", "shortid": "^2.2.15", diff --git a/packages/server/package.json b/packages/server/package.json index 1c2c245b37..c795d3e1ed 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.0.48", + "version": "1.0.49-alpha.0", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -70,9 +70,9 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "^10.0.3", - "@budibase/backend-core": "^1.0.48", - "@budibase/client": "^1.0.48", - "@budibase/string-templates": "^1.0.48", + "@budibase/backend-core": "^1.0.49-alpha.0", + "@budibase/client": "^1.0.49-alpha.0", + "@budibase/string-templates": "^1.0.49-alpha.0", "@bull-board/api": "^3.7.0", "@bull-board/koa": "^3.7.0", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 91bfc7991a..9e41666572 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.48", + "version": "1.0.49-alpha.0", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/worker/package.json b/packages/worker/package.json index f263f50a27..a3fc4b8354 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.0.48", + "version": "1.0.49-alpha.0", "description": "Budibase background service", "main": "src/index.js", "repository": { @@ -29,8 +29,8 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.0.48", - "@budibase/string-templates": "^1.0.48", + "@budibase/backend-core": "^1.0.49-alpha.0", + "@budibase/string-templates": "^1.0.49-alpha.0", "@koa/router": "^8.0.0", "@sentry/node": "^6.0.0", "@techpass/passport-openidconnect": "^0.3.0",