From 4404564c89fa3023dd899f0ee60e12fdca02d876 Mon Sep 17 00:00:00 2001 From: ewezy Date: Thu, 13 Apr 2023 17:45:04 +0800 Subject: [PATCH] Add gorm config to save all associations --- api/turing/database/database.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/turing/database/database.go b/api/turing/database/database.go index b7d89dbd7..d85e7fe67 100644 --- a/api/turing/database/database.go +++ b/api/turing/database/database.go @@ -28,7 +28,9 @@ func InitDB(cfg *config.DatabaseConfig) (*gorm.DB, error) { db, err := gorm.Open( pg.Open(connectionString(cfg)), &gorm.Config{ - Logger: logger.Default.LogMode(logger.Silent), + // This is needed to ensure that any saves to nested fields also update their respective tables + FullSaveAssociations: true, + Logger: logger.Default.LogMode(logger.Silent), }, ) if err != nil {