From 4b92bcce499b4f8bbb9e8a0f9464413b4ea0ad82 Mon Sep 17 00:00:00 2001 From: Jacob Brewer Date: Wed, 29 Jan 2025 08:11:42 +0000 Subject: [PATCH] fix(templates): moving the error handling for no changes to the correct place (#70) * moving the error handling for no changes to the correct place * Updating the err msg --- templates/_update.tmpl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/_update.tmpl b/templates/_update.tmpl index da69ee0..c790e39 100644 --- a/templates/_update.tmpl +++ b/templates/_update.tmpl @@ -37,17 +37,17 @@ func (m *{{ $struct }}) Patch(db DB, newT *{{ $struct }}) error { res, err := patcher.NewDiffSQLPatch(m, newT, patcher.WithTable({{ $struct | structify -}}TableName)) if err != nil { - return fmt.Errorf("new diff sql patch: %w", err) + switch { + case errors.Is(err, patcher.ErrNoChanges): + return nil + default: + return fmt.Errorf("new diff sql patch: %w", err) + } } sqlstr, args, err := res.GenerateSQL() if err != nil { - switch { - case errors.Is(err, patcher.ErrNoChanges): - return nil - default: - return fmt.Errorf("failed to create patch: %w", err) - } + return fmt.Errorf("failed to generate patch: %w", err) } DBLog(sqlstr, args...)