From 6d81b8fb2e14ee067a9cf8c3fa8c5ad9124e1e9e Mon Sep 17 00:00:00 2001
From: peinz <s8923496@stud.uni-frankfurt.de>
Date: Fri, 15 Mar 2024 23:47:34 +0000
Subject: [PATCH 1/2] feat: add field-mappings

---
 modules/import-export/db/convert-config.ts | 35 +++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/modules/import-export/db/convert-config.ts b/modules/import-export/db/convert-config.ts
index 5761b99ac0..0539dba717 100644
--- a/modules/import-export/db/convert-config.ts
+++ b/modules/import-export/db/convert-config.ts
@@ -33,16 +33,49 @@ export class FieldMappingEntry<
   }
 }
 
+@Entity()
+export class MaybeStringFieldMappingEntry extends FieldMappingEntry {
+  static override _class = 'MaybeStringFieldMappingEntry';
+
+  override deserialize = v => {
+    if (v === '') return null;
+    return v + '';
+  };
+}
+
 @Entity()
 export class NumberFieldMappingEntry extends FieldMappingEntry {
   static override _class = 'NumberFieldMappingEntry';
 
   override deserialize = v => {
-    if (isNaN(+v)) throw new Error(`cant convert ${v} to number while importing`);
+    if (isNaN(+v)) throw new Error(`cant convert ${v + ''} to number while importing`);
     return +v;
   };
 }
 
+@Entity()
+export class MaybeNumberFieldMappingEntry extends FieldMappingEntry {
+  static override _class = 'MaybeNumberFieldMappingEntry';
+
+  override deserialize = v => {
+    if (v === '') return null;
+    if (isNaN(+v)) throw new Error(`cant convert ${v + ''} to number while importing`);
+    return +v;
+  };
+}
+
+@Entity()
+export class BooleanFieldMappingEntry extends FieldMappingEntry {
+  static override _class = 'BooleanFieldMappingEntry';
+
+  override deserialize = v => {
+    if (v === '') return null;
+    if (v === 'false') return false;
+    if (v === 'true') return true;
+    throw new Error(`cant convert ${v + ''} to boolean while importing`);
+  };
+}
+
 /**
  * for the moment, only 1:1 relationships are supported. The nested entity is inserted with its respecive
  * uniqueIdentifierFieldName-value, then its ID is used to refer to it on the hosting entity.
-- 
GitLab


From 2144d2f0f2dbdb8f50693eed7ff262f56aa102cb Mon Sep 17 00:00:00 2001
From: peinz <s8923496@stud.uni-frankfurt.de>
Date: Mon, 18 Mar 2024 09:08:13 +0000
Subject: [PATCH 2/2] fix: remove maybeStringEntry again

---
 modules/import-export/db/convert-config.ts | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/modules/import-export/db/convert-config.ts b/modules/import-export/db/convert-config.ts
index 0539dba717..e90c33ebfe 100644
--- a/modules/import-export/db/convert-config.ts
+++ b/modules/import-export/db/convert-config.ts
@@ -33,16 +33,6 @@ export class FieldMappingEntry<
   }
 }
 
-@Entity()
-export class MaybeStringFieldMappingEntry extends FieldMappingEntry {
-  static override _class = 'MaybeStringFieldMappingEntry';
-
-  override deserialize = v => {
-    if (v === '') return null;
-    return v + '';
-  };
-}
-
 @Entity()
 export class NumberFieldMappingEntry extends FieldMappingEntry {
   static override _class = 'NumberFieldMappingEntry';
-- 
GitLab