diff --git a/packages/server/src/utilities/rowProcessor/index.ts b/packages/server/src/utilities/rowProcessor/index.ts index c44326ff42..d072802522 100644 --- a/packages/server/src/utilities/rowProcessor/index.ts +++ b/packages/server/src/utilities/rowProcessor/index.ts @@ -10,6 +10,7 @@ import { RowAttachment, Table, isAutoColumnField, + isAutoColumnNumberField, } from "@budibase/types" import { cloneDeep } from "lodash/fp" import { @@ -40,7 +41,7 @@ async function getNextAutoId( const db = context.getAppDB() for (let attempt = 0; attempt < 5; attempt++) { const schema = table.schema[column] - if (!isAutoColumnField(schema)) { + if (!isAutoColumnField(schema) && !isAutoColumnNumberField(schema)) { throw new Error(`Column ${column} is not an auto column`) } schema.lastID = (schema.lastID || 0) + 1 diff --git a/packages/types/src/documents/app/table/schema.ts b/packages/types/src/documents/app/table/schema.ts index 407199860b..d9fb405ff5 100644 --- a/packages/types/src/documents/app/table/schema.ts +++ b/packages/types/src/documents/app/table/schema.ts @@ -225,3 +225,9 @@ export function isAutoColumnField( ): field is AutoColumnFieldMetadata { return field.type === FieldType.AUTO } + +export function isAutoColumnNumberField( + field: FieldSchema +): field is NumberFieldMetadata { + return field.type === FieldType.NUMBER +}