Types
This commit is contained in:
parent
21b9bf36fd
commit
9371f9913e
|
@ -15,6 +15,7 @@ import {
|
|||
Table,
|
||||
TableSchema,
|
||||
SupportedSqlTypes,
|
||||
JsonFieldSubType,
|
||||
} from "@budibase/types"
|
||||
import { DatabaseName, getDatasource } from "../../../integrations/tests/utils"
|
||||
import { tableForDatasource } from "../../../tests/utilities/structures"
|
||||
|
@ -288,7 +289,10 @@ describe("/datasources", () => {
|
|||
name: "options",
|
||||
type: FieldType.OPTIONS,
|
||||
constraints: {
|
||||
presence: { allowEmpty: false },
|
||||
presence: {
|
||||
allowEmpty: false,
|
||||
},
|
||||
inclusion: [],
|
||||
},
|
||||
},
|
||||
[FieldType.NUMBER]: {
|
||||
|
@ -302,6 +306,10 @@ describe("/datasources", () => {
|
|||
[FieldType.ARRAY]: {
|
||||
name: "array",
|
||||
type: FieldType.ARRAY,
|
||||
constraints: {
|
||||
type: JsonFieldSubType.ARRAY,
|
||||
inclusion: [],
|
||||
},
|
||||
},
|
||||
[FieldType.DATETIME]: {
|
||||
name: "datetime",
|
||||
|
|
|
@ -32,6 +32,7 @@ import {
|
|||
TableSourceType,
|
||||
UpdatedRowEventEmitter,
|
||||
TableSchema,
|
||||
JsonFieldSubType,
|
||||
} from "@budibase/types"
|
||||
import { generator, mocks } from "@budibase/backend-core/tests"
|
||||
import _, { merge } from "lodash"
|
||||
|
@ -103,6 +104,7 @@ describe.each([
|
|||
const defaultSchema: TableSchema = {
|
||||
id: {
|
||||
type: FieldType.AUTO,
|
||||
subtype: AutoFieldSubType.AUTO_ID,
|
||||
name: "id",
|
||||
autocolumn: true,
|
||||
constraints: {
|
||||
|
@ -384,7 +386,7 @@ describe.each([
|
|||
const arrayField: FieldSchema = {
|
||||
type: FieldType.ARRAY,
|
||||
constraints: {
|
||||
type: "array",
|
||||
type: JsonFieldSubType.ARRAY,
|
||||
presence: false,
|
||||
inclusion: ["One", "Two", "Three"],
|
||||
},
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
Datasource,
|
||||
EmptyFilterOption,
|
||||
FieldType,
|
||||
JsonFieldSubType,
|
||||
RelationshipType,
|
||||
Row,
|
||||
RowSearchParams,
|
||||
|
@ -1494,7 +1495,10 @@ describe.each([
|
|||
numbers: {
|
||||
name: "numbers",
|
||||
type: FieldType.ARRAY,
|
||||
constraints: { inclusion: ["one", "two", "three"] },
|
||||
constraints: {
|
||||
type: JsonFieldSubType.ARRAY,
|
||||
inclusion: ["one", "two", "three"],
|
||||
},
|
||||
},
|
||||
})
|
||||
await createRows([{ numbers: ["one", "two"] }, { numbers: ["three"] }])
|
||||
|
|
|
@ -398,6 +398,7 @@ describe.each([
|
|||
name: "auto",
|
||||
autocolumn: true,
|
||||
type: FieldType.AUTO,
|
||||
subtype: AutoFieldSubType.AUTO_ID,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
ViewV2,
|
||||
SearchResponse,
|
||||
BasicOperator,
|
||||
AutoFieldSubType,
|
||||
} from "@budibase/types"
|
||||
import { generator, mocks } from "@budibase/backend-core/tests"
|
||||
import { DatabaseName, getDatasource } from "../../../integrations/tests/utils"
|
||||
|
@ -57,6 +58,7 @@ describe.each([
|
|||
schema: {
|
||||
id: {
|
||||
type: FieldType.AUTO,
|
||||
subtype: AutoFieldSubType.AUTO_ID,
|
||||
name: "id",
|
||||
autocolumn: true,
|
||||
constraints: {
|
||||
|
@ -242,6 +244,7 @@ describe.each([
|
|||
id: {
|
||||
name: "id",
|
||||
type: FieldType.AUTO,
|
||||
subtype: AutoFieldSubType.AUTO_ID,
|
||||
autocolumn: true,
|
||||
visible: true,
|
||||
},
|
||||
|
@ -1556,6 +1559,7 @@ describe.each([
|
|||
id: {
|
||||
name: "id",
|
||||
type: FieldType.AUTO,
|
||||
subtype: AutoFieldSubType.AUTO_ID,
|
||||
autocolumn: true,
|
||||
},
|
||||
name: {
|
||||
|
|
|
@ -17,6 +17,7 @@ import {
|
|||
AutoFieldSubType,
|
||||
Datasource,
|
||||
FieldType,
|
||||
JsonFieldSubType,
|
||||
RelationshipType,
|
||||
Row,
|
||||
SourceName,
|
||||
|
@ -131,7 +132,7 @@ export const DEFAULT_INVENTORY_TABLE_SCHEMA: Table = {
|
|||
"Item Tags": {
|
||||
type: FieldType.ARRAY,
|
||||
constraints: {
|
||||
type: FieldType.ARRAY,
|
||||
type: JsonFieldSubType.ARRAY,
|
||||
presence: {
|
||||
allowEmpty: false,
|
||||
},
|
||||
|
@ -153,7 +154,7 @@ export const DEFAULT_INVENTORY_TABLE_SCHEMA: Table = {
|
|||
Status: {
|
||||
type: FieldType.ARRAY,
|
||||
constraints: {
|
||||
type: FieldType.ARRAY,
|
||||
type: JsonFieldSubType.ARRAY,
|
||||
presence: {
|
||||
allowEmpty: false,
|
||||
},
|
||||
|
@ -291,7 +292,7 @@ export const DEFAULT_EMPLOYEE_TABLE_SCHEMA: Table = {
|
|||
"Employee Level": {
|
||||
type: FieldType.ARRAY,
|
||||
constraints: {
|
||||
type: FieldType.ARRAY,
|
||||
type: JsonFieldSubType.ARRAY,
|
||||
presence: false,
|
||||
inclusion: ["Manager", "Junior", "Senior", "Apprentice", "Contractor"],
|
||||
},
|
||||
|
@ -535,7 +536,7 @@ export const DEFAULT_EXPENSES_TABLE_SCHEMA: Table = {
|
|||
"Expense Tags": {
|
||||
type: FieldType.ARRAY,
|
||||
constraints: {
|
||||
type: FieldType.ARRAY,
|
||||
type: JsonFieldSubType.ARRAY,
|
||||
presence: {
|
||||
allowEmpty: false,
|
||||
},
|
||||
|
|
|
@ -150,22 +150,28 @@ export function generateColumnDefinition(config: {
|
|||
}).internal
|
||||
}
|
||||
|
||||
const constraints: {
|
||||
presence: boolean
|
||||
inclusion?: string[]
|
||||
} = {
|
||||
presence,
|
||||
}
|
||||
let schema: FieldSchema
|
||||
if (foundType === FieldType.OPTIONS) {
|
||||
constraints.inclusion = options
|
||||
}
|
||||
|
||||
const schema: FieldSchema = {
|
||||
type: foundType,
|
||||
externalType,
|
||||
autocolumn,
|
||||
name,
|
||||
constraints,
|
||||
schema = {
|
||||
type: foundType,
|
||||
externalType,
|
||||
autocolumn,
|
||||
name,
|
||||
constraints: {
|
||||
presence,
|
||||
inclusion: options!,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
schema = {
|
||||
type: foundType,
|
||||
externalType,
|
||||
autocolumn,
|
||||
name,
|
||||
constraints: {
|
||||
presence,
|
||||
},
|
||||
}
|
||||
}
|
||||
if (schema.type === FieldType.DATETIME) {
|
||||
schema.dateOnly = SQL_DATE_ONLY_TYPES.includes(lowerCaseType)
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
import { Datasource, FieldType, Row, Table } from "@budibase/types"
|
||||
import {
|
||||
AutoFieldSubType,
|
||||
Datasource,
|
||||
FieldType,
|
||||
Row,
|
||||
Table,
|
||||
} from "@budibase/types"
|
||||
|
||||
import TestConfiguration from "../../../../../tests/utilities/TestConfiguration"
|
||||
import { search } from "../../../../../sdk/app/rows/search"
|
||||
|
@ -56,6 +62,7 @@ describe.each([
|
|||
id: {
|
||||
name: "id",
|
||||
type: FieldType.AUTO,
|
||||
subtype: AutoFieldSubType.AUTO_ID,
|
||||
autocolumn: true,
|
||||
},
|
||||
name: {
|
||||
|
|
Loading…
Reference in New Issue