Skip to content

Commit

Permalink
Updating acording to linters to reduce nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobbrewer1 committed Feb 12, 2025
1 parent 0ad9e06 commit c2f2e7b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,17 @@ func NewDiffSQLPatch[T any](old, newT *T, opts ...PatchOpt) (*SQLPatch, error) {
continue
}

if reflect.DeepEqual(oldField.Interface(), copyField.Interface()) {
// Field is the same, set it to zero or nil. Add it to be ignored in the patch
if patch.ignoreFields == nil {
patch.ignoreFields = make([]string, 0)
}
patch.ignoreFields = append(patch.ignoreFields, oldElem.Type().Field(i).Name)
if !reflect.DeepEqual(oldField.Interface(), copyField.Interface()) {
continue
}

// Field is the same, set it to zero or nil. Add it to be ignored in the patch
if patch.ignoreFields == nil {
patch.ignoreFields = make([]string, 0)
}
patch.ignoreFields = append(patch.ignoreFields, oldElem.Type().Field(i).Name)
continue

}

patch.patchGen(old)
Expand Down

0 comments on commit c2f2e7b

Please sign in to comment.