diff --git a/lerna.json b/lerna.json index 0efaf75283..32b7d8f766 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "2.29.1", + "version": "2.29.3", "npmClient": "yarn", "packages": [ "packages/*", diff --git a/packages/account-portal b/packages/account-portal index b600cca314..ff16525b73 160000 --- a/packages/account-portal +++ b/packages/account-portal @@ -1 +1 @@ -Subproject commit b600cca314a5cc9971e44d46047d1a0019b46b08 +Subproject commit ff16525b73c5751d344f5c161a682609c0a993f2 diff --git a/packages/backend-core/src/db/constants.ts b/packages/backend-core/src/db/constants.ts index 69c98fe569..bfa7595d62 100644 --- a/packages/backend-core/src/db/constants.ts +++ b/packages/backend-core/src/db/constants.ts @@ -1,5 +1,14 @@ -export { - CONSTANT_INTERNAL_ROW_COLS, - CONSTANT_EXTERNAL_ROW_COLS, - isInternalColumnName, -} from "@budibase/shared-core" +export const CONSTANT_INTERNAL_ROW_COLS = [ + "_id", + "_rev", + "type", + "createdAt", + "updatedAt", + "tableId", +] as const + +export const CONSTANT_EXTERNAL_ROW_COLS = ["_id", "_rev", "tableId"] as const + +export function isInternalColumnName(name: string): boolean { + return (CONSTANT_INTERNAL_ROW_COLS as readonly string[]).includes(name) +} diff --git a/packages/backend-core/src/sql/sql.ts b/packages/backend-core/src/sql/sql.ts index 72ff8d4578..cdc5f3d3c8 100644 --- a/packages/backend-core/src/sql/sql.ts +++ b/packages/backend-core/src/sql/sql.ts @@ -449,8 +449,12 @@ class InternalBuilder { query = query.orderBy(`${aliased}.${key}`, direction, nulls) } } - // always add sorting by the primary key - make sure result is deterministic - query = query.orderBy(`${aliased}.${primaryKey[0]}`) + + // add sorting by the primary key if the result isn't already sorted by it, + // to make sure result is deterministic + if (!sort || sort[primaryKey[0]] === undefined) { + query = query.orderBy(`${aliased}.${primaryKey[0]}`) + } return query } @@ -604,7 +608,8 @@ class InternalBuilder { if (!primary) { throw new Error("Primary key is required for upsert") } - return query.insert(parsedBody).onConflict(primary).merge() + const ret = query.insert(parsedBody).onConflict(primary).merge() + return ret } else if (this.client === SqlClient.MS_SQL) { // No upsert or onConflict support in MSSQL yet, see: // https://github.com/knex/knex/pull/6050 diff --git a/packages/backend-core/tests/core/utilities/structures/accounts.ts b/packages/backend-core/tests/core/utilities/structures/accounts.ts index 7dcc2de116..29453ad60a 100644 --- a/packages/backend-core/tests/core/utilities/structures/accounts.ts +++ b/packages/backend-core/tests/core/utilities/structures/accounts.ts @@ -24,7 +24,6 @@ export const account = (partial: Partial = {}): Account => { createdAt: Date.now(), verified: true, verificationSent: true, - tier: "FREE", // DEPRECATED authType: AuthType.PASSWORD, name: generator.name(), size: "10+", diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index d79eedd194..17ecd8f844 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -17,8 +17,6 @@ SWITCHABLE_TYPES, ValidColumnNameRegex, helpers, - CONSTANT_INTERNAL_ROW_COLS, - CONSTANT_EXTERNAL_ROW_COLS, } from "@budibase/shared-core" import { createEventDispatcher, getContext, onMount } from "svelte" import { cloneDeep } from "lodash/fp" @@ -54,6 +52,7 @@ const DATE_TYPE = FieldType.DATETIME const dispatch = createEventDispatcher() + const PROHIBITED_COLUMN_NAMES = ["type", "_id", "_rev", "tableId"] const { dispatch: gridDispatch, rows } = getContext("grid") export let field @@ -488,27 +487,20 @@ }) } const newError = {} - const prohibited = externalTable - ? CONSTANT_EXTERNAL_ROW_COLS - : CONSTANT_INTERNAL_ROW_COLS if (!externalTable && fieldInfo.name?.startsWith("_")) { newError.name = `Column name cannot start with an underscore.` } else if (fieldInfo.name && !fieldInfo.name.match(ValidColumnNameRegex)) { newError.name = `Illegal character; must be alpha-numeric.` - } else if ( - prohibited.some( - name => fieldInfo?.name?.toLowerCase() === name.toLowerCase() - ) - ) { - newError.name = `${prohibited.join( + } else if (PROHIBITED_COLUMN_NAMES.some(name => fieldInfo.name === name)) { + newError.name = `${PROHIBITED_COLUMN_NAMES.join( ", " - )} are not allowed as column names - case insensitive.` + )} are not allowed as column names` } else if (inUse($tables.selected, fieldInfo.name, originalName)) { newError.name = `Column name already in use.` } if (fieldInfo.type === FieldType.AUTO && !fieldInfo.subtype) { - newError.subtype = `Auto Column requires a type.` + newError.subtype = `Auto Column requires a type` } if (fieldInfo.fieldName && fieldInfo.tableId) { diff --git a/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte b/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte index de56fa8ce5..80655d1099 100644 --- a/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte +++ b/packages/builder/src/components/backend/TableNavigator/ExistingTableDataImport.svelte @@ -1,9 +1,14 @@