From f159fa3d74b90963812bbe29dac1290aef8dc775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn?= Date: Fri, 6 May 2016 14:10:43 +0200 Subject: [PATCH] association: dont execute Append/Replace/Delete if Error already present --- association.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/association.go b/association.go index cd8fd912..0f94683d 100644 --- a/association.go +++ b/association.go @@ -22,6 +22,10 @@ func (association *Association) Find(value interface{}) *Association { // Append append new associations for many2many, has_many, replace current association for has_one, belongs_to func (association *Association) Append(values ...interface{}) *Association { + if association.Error != nil { + return association + } + if relationship := association.field.Relationship; relationship.Kind == "has_one" { return association.Replace(values...) } @@ -30,6 +34,10 @@ func (association *Association) Append(values ...interface{}) *Association { // Replace replace current associations with new one func (association *Association) Replace(values ...interface{}) *Association { + if association.Error != nil { + return association + } + var ( relationship = association.field.Relationship scope = association.scope @@ -118,6 +126,10 @@ func (association *Association) Replace(values ...interface{}) *Association { // Delete remove relationship between source & passed arguments, but won't delete those arguments func (association *Association) Delete(values ...interface{}) *Association { + if association.Error != nil { + return association + } + var ( relationship = association.field.Relationship scope = association.scope