diff --git a/lerna.json b/lerna.json index 523485d1f3..801ba1b871 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.0.46-alpha.8", + "version": "1.0.48", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index a3448828bb..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.46-alpha.8", + "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 94c8cab3f6..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.46-alpha.8", + "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 6723f72a82..f956a22027 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.0.46-alpha.8", + "version": "1.0.48", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.0.46-alpha.8", - "@budibase/client": "^1.0.46-alpha.8", + "@budibase/bbui": "^1.0.48", + "@budibase/client": "^1.0.48", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^1.0.46-alpha.8", + "@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/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 1fa5c6e073..c6f33b5d31 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" @@ -241,6 +243,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/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} diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 50413fcb22..d07c245b21 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/cli/package.json b/packages/cli/package.json index 7b02cf7296..016de84bef 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.0.46-alpha.8", + "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 c6704a5151..6b9aa18a2b 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.0.46-alpha.8", + "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.46-alpha.8", + "@budibase/bbui": "^1.0.48", "@budibase/standard-components": "^0.9.139", - "@budibase/string-templates": "^1.0.46-alpha.8", + "@budibase/string-templates": "^1.0.48", "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 41278a434e..1c2c245b37 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.46-alpha.8", + "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.46-alpha.8", - "@budibase/client": "^1.0.46-alpha.8", - "@budibase/string-templates": "^1.0.46-alpha.8", + "@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/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 || diff --git a/packages/server/src/api/controllers/table/utils.js b/packages/server/src/api/controllers/table/utils.js index 86e2837e15..0f4c75e197 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, @@ -348,6 +352,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 @@ -358,7 +379,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 cf5e15a9fb..ac18196edc 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 b9e643e26a..8fe8fedcc8 100644 --- a/packages/server/src/integrations/utils.ts +++ b/packages/server/src/integrations/utils.ts @@ -178,6 +178,7 @@ function shouldCopySpecialColumn( ) { return ( column.type === FieldTypes.OPTIONS || + column.type === FieldTypes.ARRAY || ((!fetchedColumn || fetchedColumn.type === FieldTypes.NUMBER) && column.type === FieldTypes.BOOLEAN) ) diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index bde8489166..91bfc7991a 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.0.46-alpha.8", + "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 85a4080cc3..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.46-alpha.8", + "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.46-alpha.8", - "@budibase/string-templates": "^1.0.46-alpha.8", + "@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",