Fix row.spec.ts
This commit is contained in:
parent
49fad46025
commit
99ecefaedf
|
@ -10,6 +10,7 @@ import {
|
||||||
RowAttachment,
|
RowAttachment,
|
||||||
Table,
|
Table,
|
||||||
isAutoColumnField,
|
isAutoColumnField,
|
||||||
|
isAutoColumnNumberField,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import {
|
import {
|
||||||
|
@ -40,7 +41,7 @@ async function getNextAutoId(
|
||||||
const db = context.getAppDB()
|
const db = context.getAppDB()
|
||||||
for (let attempt = 0; attempt < 5; attempt++) {
|
for (let attempt = 0; attempt < 5; attempt++) {
|
||||||
const schema = table.schema[column]
|
const schema = table.schema[column]
|
||||||
if (!isAutoColumnField(schema)) {
|
if (!isAutoColumnField(schema) && !isAutoColumnNumberField(schema)) {
|
||||||
throw new Error(`Column ${column} is not an auto column`)
|
throw new Error(`Column ${column} is not an auto column`)
|
||||||
}
|
}
|
||||||
schema.lastID = (schema.lastID || 0) + 1
|
schema.lastID = (schema.lastID || 0) + 1
|
||||||
|
|
|
@ -225,3 +225,9 @@ export function isAutoColumnField(
|
||||||
): field is AutoColumnFieldMetadata {
|
): field is AutoColumnFieldMetadata {
|
||||||
return field.type === FieldType.AUTO
|
return field.type === FieldType.AUTO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isAutoColumnNumberField(
|
||||||
|
field: FieldSchema
|
||||||
|
): field is NumberFieldMetadata {
|
||||||
|
return field.type === FieldType.NUMBER
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue