1
0
Fork 0
mirror of synced 2024-09-18 10:20:11 +12:00

Save timeonly on external db

This commit is contained in:
Adria Navarro 2024-05-17 15:55:27 +02:00
parent 16e58a38ea
commit a81626005c

View file

@ -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