refactor: combine sqlite json and simple-json handling (#9937)

This commit is contained in:
Bengt Weiße 2023-04-15 11:37:46 +02:00 committed by GitHub
parent 80ae9043ae
commit 7ee6232143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -341,12 +341,13 @@ export abstract class AbstractSqliteDriver implements Driver {
// to string conversation needs because SQLite stores date as integer number, when date came as Object
// TODO: think about `toUTC` conversion
return DateUtils.mixedDateToUtcDatetimeString(value)
} else if (columnMetadata.type === "json") {
return JSON.stringify(value)
} else if (
columnMetadata.type === "json" ||
columnMetadata.type === "simple-json"
) {
return DateUtils.simpleJsonToString(value)
} else if (columnMetadata.type === "simple-array") {
return DateUtils.simpleArrayToString(value)
} else if (columnMetadata.type === "simple-json") {
return DateUtils.simpleJsonToString(value)
} else if (columnMetadata.type === "simple-enum") {
return DateUtils.simpleEnumToString(value)
}
@ -408,12 +409,13 @@ export abstract class AbstractSqliteDriver implements Driver {
value = DateUtils.mixedDateToDateString(value)
} else if (columnMetadata.type === "time") {
value = DateUtils.mixedTimeToString(value)
} else if (columnMetadata.type === "json") {
value = typeof value === "string" ? JSON.parse(value) : value
} else if (
columnMetadata.type === "json" ||
columnMetadata.type === "simple-json"
) {
value = DateUtils.stringToSimpleJson(value)
} else if (columnMetadata.type === "simple-array") {
value = DateUtils.stringToSimpleArray(value)
} else if (columnMetadata.type === "simple-json") {
value = DateUtils.stringToSimpleJson(value)
} else if (columnMetadata.type === "simple-enum") {
value = DateUtils.stringToSimpleEnum(value, columnMetadata)
} else if (columnMetadata.type === Number) {