diff --git a/packages/server/src/api/routes/tests/table.spec.ts b/packages/server/src/api/routes/tests/table.spec.ts index f56c6e4e44..aabb64b763 100644 --- a/packages/server/src/api/routes/tests/table.spec.ts +++ b/packages/server/src/api/routes/tests/table.spec.ts @@ -1,6 +1,11 @@ import { generator } from "@budibase/backend-core/tests" import { events, context } from "@budibase/backend-core" -import { FieldType, Table, ViewCalculation } from "@budibase/types" +import { + FieldType, + SaveTableRequest, + Table, + ViewCalculation, +} from "@budibase/types" import { checkBuilderEndpoint } from "./utilities/TestFunctions" import * as setup from "./utilities" const { basicTable } = setup.structures @@ -47,7 +52,7 @@ describe("/tables", () => { }) it("creates a table via data import", async () => { - const table = basicTable() + const table: SaveTableRequest = basicTable() table.rows = [{ name: "test-name", description: "test-desc" }] const res = await createTable(table) diff --git a/packages/server/src/utilities/schema.ts b/packages/server/src/utilities/schema.ts index 52adc79298..97e67e92a7 100644 --- a/packages/server/src/utilities/schema.ts +++ b/packages/server/src/utilities/schema.ts @@ -162,6 +162,8 @@ export function parse(rows: Rows, schema: Schema): Rows { parsedRow[columnName] = columnData ? new Date(columnData).toISOString() : columnData + } else if (columnType === FieldTypes.BB_REFERENCE) { + parsedRow[columnName] = columnData && parseCsvExport(columnData) } else { parsedRow[columnName] = columnData } diff --git a/packages/types/src/api/web/app/table.ts b/packages/types/src/api/web/app/table.ts index ff288811c9..0885dac72a 100644 --- a/packages/types/src/api/web/app/table.ts +++ b/packages/types/src/api/web/app/table.ts @@ -1,4 +1,5 @@ import { + Row, Table, TableRequest, TableSchema, @@ -18,6 +19,8 @@ export interface TableResponse extends Table { export type FetchTablesResponse = TableResponse[] -export interface SaveTableRequest extends TableRequest {} +export interface SaveTableRequest extends TableRequest { + rows?: Row[] +} export type SaveTableResponse = Table diff --git a/packages/types/src/documents/app/table/table.ts b/packages/types/src/documents/app/table/table.ts index 76b2c587b2..5174ec608f 100644 --- a/packages/types/src/documents/app/table/table.ts +++ b/packages/types/src/documents/app/table/table.ts @@ -15,7 +15,6 @@ export interface Table extends Document { constrained?: string[] sql?: boolean indexes?: { [key: string]: any } - rows?: { [key: string]: any } created?: boolean rowHeight?: number }