Skip to content

Commit

Permalink
fix(templates): moving the error handling for no changes to the corre…
Browse files Browse the repository at this point in the history
…ct place (#70)

* moving the error handling for no changes to the correct place

* Updating the err msg
  • Loading branch information
Jacobbrewer1 authored Jan 29, 2025
1 parent 8c442ac commit 4b92bcc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions templates/_update.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down

0 comments on commit 4b92bcc

Please sign in to comment.