Fix autoid numbers
This commit is contained in:
parent
248c44ac2a
commit
3f6d48da1f
|
@ -12,6 +12,7 @@ import {
|
||||||
Row,
|
Row,
|
||||||
RelationshipType,
|
RelationshipType,
|
||||||
AutoColumnFieldMetadata,
|
AutoColumnFieldMetadata,
|
||||||
|
FieldType,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
export const DEFAULT_JOBS_TABLE_ID = "ta_bb_jobs"
|
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) {
|
function syncLastIds(table: Table, rowCount: number) {
|
||||||
Object.keys(table.schema).forEach(key => {
|
Object.keys(table.schema).forEach(key => {
|
||||||
const entry = table.schema[key] as AutoColumnFieldMetadata
|
const entry = table.schema[key]
|
||||||
if (entry.autocolumn && entry.subtype == "autoID") {
|
if (
|
||||||
|
entry.autocolumn &&
|
||||||
|
entry.type === FieldType.NUMBER &&
|
||||||
|
entry.subtype == AutoFieldSubTypes.AUTO_ID
|
||||||
|
) {
|
||||||
entry.lastID = rowCount
|
entry.lastID = rowCount
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -70,6 +70,7 @@ export interface AutoColumnFieldMetadata
|
||||||
export interface NumberFieldMetadata extends Omit<BaseFieldSchema, "subtype"> {
|
export interface NumberFieldMetadata extends Omit<BaseFieldSchema, "subtype"> {
|
||||||
type: FieldType.NUMBER
|
type: FieldType.NUMBER
|
||||||
subtype?: AutoFieldSubTypes.AUTO_ID
|
subtype?: AutoFieldSubTypes.AUTO_ID
|
||||||
|
lastID?: number
|
||||||
autoReason?: AutoReason.FOREIGN_KEY
|
autoReason?: AutoReason.FOREIGN_KEY
|
||||||
// used specifically when Budibase generates external tables, this denotes if a number field
|
// used specifically when Budibase generates external tables, this denotes if a number field
|
||||||
// is a foreign key used for a many-to-many relationship
|
// is a foreign key used for a many-to-many relationship
|
||||||
|
|
Loading…
Reference in New Issue