From a9926a38624003284081fd452822c2de727678b5 Mon Sep 17 00:00:00 2001 From: wgwntp <593034713@qq.com> Date: Thu, 1 Aug 2019 16:20:07 +0800 Subject: [PATCH 1/3] Clear errors after handle --- exchange.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exchange.go b/exchange.go index 20f06ab..08a9b7c 100644 --- a/exchange.go +++ b/exchange.go @@ -125,8 +125,9 @@ func (res *Resource) Import(container Container, context *qor.Context, callbacks if errors, ok := err.(errorsInterface); ok { for _, err := range errors.GetErrors() { handleError(err) - } + //Avoid repeated handle errors , clear context.Errors + context.Errors = qor.Errors{} } else if errValidations, ok := err.(*validations.Error); ok { for idx, cell := range progress.Cells { if cell.Header == errValidations.Column { From e0e755437b50f5ef064dbb6cd91bd5ceb8301da8 Mon Sep 17 00:00:00 2001 From: wgwntp <593034713@qq.com> Date: Fri, 2 Aug 2019 15:11:48 +0800 Subject: [PATCH 2/3] Make logic more clearly --- exchange.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exchange.go b/exchange.go index 08a9b7c..53e8571 100644 --- a/exchange.go +++ b/exchange.go @@ -161,6 +161,7 @@ func (res *Resource) Import(container Container, context *qor.Context, callbacks } } else { handleError(context.Errors) + clearContextErrorsForCurrentRow(context) } } else { handleError(err) @@ -179,6 +180,9 @@ func (res *Resource) Import(container Container, context *qor.Context, callbacks } return err } +func clearContextErrorsForCurrentRow(context *qor.Context) { + context.Errors = qor.Errors{} +} // Export used export data from a exchange Resource // product.Export(csv.New("products.csv"), context) From 31a25a5ef5876157806f79d9ab00f7b823ecd0ae Mon Sep 17 00:00:00 2001 From: wgwntp <593034713@qq.com> Date: Fri, 2 Aug 2019 15:14:31 +0800 Subject: [PATCH 3/3] Remove unused code --- exchange.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/exchange.go b/exchange.go index 53e8571..73f594d 100644 --- a/exchange.go +++ b/exchange.go @@ -126,8 +126,6 @@ func (res *Resource) Import(container Container, context *qor.Context, callbacks for _, err := range errors.GetErrors() { handleError(err) } - //Avoid repeated handle errors , clear context.Errors - context.Errors = qor.Errors{} } else if errValidations, ok := err.(*validations.Error); ok { for idx, cell := range progress.Cells { if cell.Header == errValidations.Column {