From c0d877521c6d94f5a78bd397c1dd2bce63a02397 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Fri, 11 Aug 2023 18:29:24 +0200 Subject: [PATCH] Prevent typeorm from attempting to update nullable columns on every sync This is a bug in typeorm, see: https://github.com/typeorm/typeorm/issues/3076#issuecomment-703128687 --- src/entities/LegalPerson.entity.ts | 10 ++++++---- src/entities/user.entity.ts | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/entities/LegalPerson.entity.ts b/src/entities/LegalPerson.entity.ts index 5b9aa76..6c4751d 100644 --- a/src/entities/LegalPerson.entity.ts +++ b/src/entities/LegalPerson.entity.ts @@ -20,10 +20,12 @@ class LegalPersonEntity { did: string = ""; - @Column({ nullable: true }) + // Explicit default to workaround a bug in typeorm: https://github.com/typeorm/typeorm/issues/3076#issuecomment-703128687 + @Column({ nullable: true, default: () => "NULL" }) client_id: string = ""; - - @Column({ nullable: true }) + + // Explicit default to workaround a bug in typeorm: https://github.com/typeorm/typeorm/issues/3076#issuecomment-703128687 + @Column({ nullable: true, default: () => "NULL" }) client_secret: string = ""; } @@ -196,4 +198,4 @@ export { getLegalPersonByDID, getAllLegalPersonsDIDs, getLegalPersonByUrl -} \ No newline at end of file +} diff --git a/src/entities/user.entity.ts b/src/entities/user.entity.ts index 568b463..56028e9 100644 --- a/src/entities/user.entity.ts +++ b/src/entities/user.entity.ts @@ -26,11 +26,13 @@ class UserEntity { keys: Buffer = Buffer.from(""); - @Column( {type: "blob", nullable: true }) - fcmToken: Buffer = Buffer.from(""); + // Explicit default to workaround a bug in typeorm: https://github.com/typeorm/typeorm/issues/3076#issuecomment-703128687 + @Column({ type: "blob", nullable: true, default: () => "NULL" }) + fcmToken: Buffer; - @Column( { type: "blob", nullable: true }) - browserFcmToken: Buffer = Buffer.from(""); + // Explicit default to workaround a bug in typeorm: https://github.com/typeorm/typeorm/issues/3076#issuecomment-703128687 + @Column( { type: "blob", nullable: true, default: () => "NULL" }) + browserFcmToken: Buffer; @Column({ type: "bool", default: false }) isAdmin: boolean = false;