Save timeonly on external db
This commit is contained in:
parent
16e58a38ea
commit
a81626005c
|
@ -1,3 +1,4 @@
|
||||||
|
import dayjs from "dayjs"
|
||||||
import {
|
import {
|
||||||
AutoFieldSubType,
|
AutoFieldSubType,
|
||||||
AutoReason,
|
AutoReason,
|
||||||
|
@ -285,13 +286,10 @@ export class ExternalRequest<T extends Operation> {
|
||||||
// parse floats/numbers
|
// parse floats/numbers
|
||||||
if (field.type === FieldType.NUMBER && !isNaN(parseFloat(row[key]))) {
|
if (field.type === FieldType.NUMBER && !isNaN(parseFloat(row[key]))) {
|
||||||
newRow[key] = parseFloat(row[key])
|
newRow[key] = parseFloat(row[key])
|
||||||
}
|
} else if (field.type === FieldType.LINK) {
|
||||||
// if its not a link then just copy it over
|
const { tableName: linkTableName } = breakExternalTableId(
|
||||||
if (field.type !== FieldType.LINK) {
|
field?.tableId
|
||||||
newRow[key] = row[key]
|
)
|
||||||
continue
|
|
||||||
}
|
|
||||||
const { tableName: linkTableName } = breakExternalTableId(field?.tableId)
|
|
||||||
// table has to exist for many to many
|
// table has to exist for many to many
|
||||||
if (!linkTableName || !this.tables[linkTableName]) {
|
if (!linkTableName || !this.tables[linkTableName]) {
|
||||||
continue
|
continue
|
||||||
|
@ -306,7 +304,8 @@ export class ExternalRequest<T extends Operation> {
|
||||||
if (typeof row[key] === "string") {
|
if (typeof row[key] === "string") {
|
||||||
id = decodeURIComponent(row[key]).match(/\[(.*?)\]/)?.[1]
|
id = decodeURIComponent(row[key]).match(/\[(.*?)\]/)?.[1]
|
||||||
}
|
}
|
||||||
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(id)[0]
|
newRow[field.foreignKey || linkTablePrimary] =
|
||||||
|
breakRowIdField(id)[0]
|
||||||
} else {
|
} else {
|
||||||
// Removing from both new and row, as we don't know if it has already been processed
|
// Removing from both new and row, as we don't know if it has already been processed
|
||||||
row[field.foreignKey || linkTablePrimary] = null
|
row[field.foreignKey || linkTablePrimary] = null
|
||||||
|
@ -345,6 +344,15 @@ export class ExternalRequest<T extends Operation> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (
|
||||||
|
field.type === FieldType.DATETIME &&
|
||||||
|
field.timeOnly &&
|
||||||
|
row[key]
|
||||||
|
) {
|
||||||
|
newRow[key] = dayjs(row[key]).format("HH:mm")
|
||||||
|
} else {
|
||||||
|
newRow[key] = row[key]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// we return the relationships that may need to be created in the through table
|
// we return the relationships that may need to be created in the through table
|
||||||
// we do this so that if the ID is generated by the DB it can be inserted
|
// we do this so that if the ID is generated by the DB it can be inserted
|
||||||
|
|
Loading…
Reference in New Issue