From 2940c553eb9763e966effbdca702e2d5b2b255da Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sat, 10 Feb 2018 18:01:41 +0800 Subject: [PATCH] Add DB setting gorm:association_save_reference --- callback_save.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/callback_save.go b/callback_save.go index 243c986e..ef267141 100644 --- a/callback_save.go +++ b/callback_save.go @@ -53,7 +53,9 @@ func saveAssociationCheck(scope *Scope, field *Field) (autoUpdate bool, autoCrea autoCreate = checkTruth(value) } - if value, ok := field.TagSettings["ASSOCIATION_SAVE_REFERENCE"]; ok { + if value, ok := scope.Get("gorm:association_save_reference"); ok { + saveReference = checkTruth(value) + } else if value, ok := field.TagSettings["ASSOCIATION_SAVE_REFERENCE"]; ok { saveReference = checkTruth(value) } }