Support boolean and bigint fields having default values.
This commit is contained in:
parent
5cf0e334c2
commit
67fea783bb
|
@ -835,6 +835,62 @@ describe.each([
|
|||
})
|
||||
})
|
||||
|
||||
describe("boolean column", () => {
|
||||
beforeAll(async () => {
|
||||
table = await config.api.table.save(
|
||||
saveTableRequest({
|
||||
schema: {
|
||||
active: {
|
||||
name: "active",
|
||||
type: FieldType.BOOLEAN,
|
||||
default: "true",
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a new row with a default value successfully", async () => {
|
||||
const row = await config.api.row.save(table._id!, {})
|
||||
expect(row.active).toEqual(true)
|
||||
})
|
||||
|
||||
it("does not use default value if value specified", async () => {
|
||||
const row = await config.api.row.save(table._id!, {
|
||||
active: false,
|
||||
})
|
||||
expect(row.active).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe("bigint column", () => {
|
||||
beforeAll(async () => {
|
||||
table = await config.api.table.save(
|
||||
saveTableRequest({
|
||||
schema: {
|
||||
bigNumber: {
|
||||
name: "bigNumber",
|
||||
type: FieldType.BIGINT,
|
||||
default: "1234567890",
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("creates a new row with a default value successfully", async () => {
|
||||
const row = await config.api.row.save(table._id!, {})
|
||||
expect(row.bigNumber).toEqual("1234567890")
|
||||
})
|
||||
|
||||
it("does not use default value if value specified", async () => {
|
||||
const row = await config.api.row.save(table._id!, {
|
||||
bigNumber: "9876543210",
|
||||
})
|
||||
expect(row.bigNumber).toEqual("9876543210")
|
||||
})
|
||||
})
|
||||
|
||||
describe("bindings", () => {
|
||||
describe("string column", () => {
|
||||
beforeAll(async () => {
|
||||
|
|
|
@ -57,12 +57,12 @@ const allowDefaultColumnByType: Record<FieldType, boolean> = {
|
|||
[FieldType.STRING]: true,
|
||||
[FieldType.OPTIONS]: true,
|
||||
[FieldType.ARRAY]: true,
|
||||
[FieldType.BIGINT]: true,
|
||||
[FieldType.BOOLEAN]: true,
|
||||
|
||||
[FieldType.AUTO]: false,
|
||||
[FieldType.INTERNAL]: false,
|
||||
[FieldType.BARCODEQR]: false,
|
||||
[FieldType.BIGINT]: false,
|
||||
[FieldType.BOOLEAN]: false,
|
||||
[FieldType.FORMULA]: false,
|
||||
[FieldType.AI]: false,
|
||||
[FieldType.ATTACHMENTS]: false,
|
||||
|
|
|
@ -198,6 +198,16 @@ interface BaseFieldSchema extends UIFieldMetadata {
|
|||
subtype?: never
|
||||
}
|
||||
|
||||
interface BooleanFieldMetadata extends BaseFieldSchema {
|
||||
type: FieldType.BOOLEAN
|
||||
default?: string
|
||||
}
|
||||
|
||||
interface BigIntFieldMetadata extends BaseFieldSchema {
|
||||
type: FieldType.BIGINT
|
||||
default?: string
|
||||
}
|
||||
|
||||
interface OtherFieldMetadata extends BaseFieldSchema {
|
||||
type: Exclude<
|
||||
FieldType,
|
||||
|
@ -214,6 +224,8 @@ interface OtherFieldMetadata extends BaseFieldSchema {
|
|||
| FieldType.STRING
|
||||
| FieldType.ARRAY
|
||||
| FieldType.OPTIONS
|
||||
| FieldType.BOOLEAN
|
||||
| FieldType.BIGINT
|
||||
>
|
||||
}
|
||||
|
||||
|
@ -233,6 +245,8 @@ export type FieldSchema =
|
|||
| BBReferenceSingleFieldMetadata
|
||||
| ArrayFieldMetadata
|
||||
| OptionsFieldMetadata
|
||||
| BooleanFieldMetadata
|
||||
| BigIntFieldMetadata
|
||||
|
||||
export interface TableSchema {
|
||||
[key: string]: FieldSchema
|
||||
|
|
Loading…
Reference in New Issue