Merge pull request #8125 from Budibase/fix/table-options-csv

Fixing options type import with CSV
This commit is contained in:
Michael Drury 2022-10-05 10:06:06 +01:00 committed by GitHub
commit 3f4bdece64
3 changed files with 12 additions and 4 deletions

View File

@ -22,7 +22,7 @@ export async function addRev(
}
/**
* Performs a case insensitive search on the provided documents, using the
* Performs a case in-sensitive search on the provided documents, using the
* provided key and value. This will be a string based search, using the
* startsWith function.
*/

View File

@ -14,8 +14,10 @@ import {
fixAutoColumnSubType,
} from "../../../utilities/rowProcessor"
import { runStaticFormulaChecks } from "./bulkFormula"
import { Table } from "../../../definitions/common"
import { Table } from "@budibase/types"
import { quotas } from "@budibase/pro"
import { isEqual } from "lodash"
import { cloneDeep } from "lodash/fp"
function checkAutoColumns(table: Table, oldTable: Table) {
if (!table.schema) {
@ -123,10 +125,16 @@ export async function save(ctx: any) {
if (updatedRows && updatedRows.length !== 0) {
await db.bulkDocs(updatedRows)
}
const result = await db.put(tableToSave)
let result = await db.put(tableToSave)
tableToSave._rev = result.rev
const savedTable = cloneDeep(tableToSave)
tableToSave = await tableSaveFunctions.after(tableToSave)
// the table may be updated as part of the table save after functionality - need to write it
if (!isEqual(savedTable, tableToSave)) {
result = await db.put(tableToSave)
tableToSave._rev = result.rev
}
// has to run after, make sure it has _id
await runStaticFormulaChecks(tableToSave, { oldTable, deletion: null })
return tableToSave

View File

@ -245,7 +245,7 @@ class TableSaveFunctions {
// after saving
async after(table: any) {
table = await handleSearchIndexes(table)
await handleDataImport(this.user, table, this.dataImport)
table = await handleDataImport(this.user, table, this.dataImport)
return table
}