Add DB setting gorm:association_save_reference

This commit is contained in:
Jinzhu 2018-02-10 18:01:41 +08:00
parent b2b568daa8
commit 2940c553eb
1 changed files with 3 additions and 1 deletions

View File

@ -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)
}
}