Fix autoid numbers

This commit is contained in:
Adria Navarro 2023-10-11 13:03:05 +02:00
parent 248c44ac2a
commit 3f6d48da1f
2 changed files with 8 additions and 2 deletions

View File

@ -12,6 +12,7 @@ import {
Row,
RelationshipType,
AutoColumnFieldMetadata,
FieldType,
} from "@budibase/types"
export const DEFAULT_JOBS_TABLE_ID = "ta_bb_jobs"
@ -32,8 +33,12 @@ export const DEFAULT_BB_DATASOURCE = defaultDatasource
function syncLastIds(table: Table, rowCount: number) {
Object.keys(table.schema).forEach(key => {
const entry = table.schema[key] as AutoColumnFieldMetadata
if (entry.autocolumn && entry.subtype == "autoID") {
const entry = table.schema[key]
if (
entry.autocolumn &&
entry.type === FieldType.NUMBER &&
entry.subtype == AutoFieldSubTypes.AUTO_ID
) {
entry.lastID = rowCount
}
})

View File

@ -70,6 +70,7 @@ export interface AutoColumnFieldMetadata
export interface NumberFieldMetadata extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.NUMBER
subtype?: AutoFieldSubTypes.AUTO_ID
lastID?: number
autoReason?: AutoReason.FOREIGN_KEY
// used specifically when Budibase generates external tables, this denotes if a number field
// is a foreign key used for a many-to-many relationship