Skip to content

Commit e5fd386

Browse files
committed
fix: integer formatting options in sequence comparison
1 parent 4ce3439 commit e5fd386

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

internal/diff/engine.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package diff
22

33
import (
44
"fmt"
5-
"strconv"
65
"strings"
76

87
"github.com/meru143/dbdiff/pkg/types"
@@ -136,17 +135,17 @@ func (e *DiffEngine) compareSequences() types.DiffList {
136135
Type: types.DiffAlter,
137136
Object: types.ObjectSequence,
138137
Name: name,
139-
OldValue: strconv.FormatInt(targetSeq.Start, 10),
140-
NewValue: strconv.FormatInt(sourceSeq.Start, 10),
138+
OldValue: fmt.Sprintf("%d", targetSeq.Start),
139+
NewValue: fmt.Sprintf("%d", sourceSeq.Start),
141140
})
142141
}
143142
if sourceSeq.Increment != targetSeq.Increment {
144143
differences = append(differences, types.Diff{
145144
Type: types.DiffAlter,
146145
Object: types.ObjectSequence,
147146
Name: name,
148-
OldValue: "INCREMENT BY " + strconv.FormatInt(targetSeq.Increment, 10),
149-
NewValue: "INCREMENT BY " + strconv.FormatInt(sourceSeq.Increment, 10),
147+
OldValue: fmt.Sprintf("INCREMENT BY %d", targetSeq.Increment),
148+
NewValue: fmt.Sprintf("INCREMENT BY %d", sourceSeq.Increment),
150149
})
151150
}
152151
// Min value change
@@ -155,8 +154,8 @@ func (e *DiffEngine) compareSequences() types.DiffList {
155154
Type: types.DiffAlter,
156155
Object: types.ObjectSequence,
157156
Name: name,
158-
OldValue: "MINVALUE " + strconv.FormatInt(targetSeq.MinValue, 10),
159-
NewValue: "MINVALUE " + strconv.FormatInt(sourceSeq.MinValue, 10),
157+
OldValue: fmt.Sprintf("MINVALUE %d", targetSeq.MinValue),
158+
NewValue: fmt.Sprintf("MINVALUE %d", sourceSeq.MinValue),
160159
})
161160
}
162161
// Max value change
@@ -165,8 +164,8 @@ func (e *DiffEngine) compareSequences() types.DiffList {
165164
Type: types.DiffAlter,
166165
Object: types.ObjectSequence,
167166
Name: name,
168-
OldValue: "MAXVALUE " + strconv.FormatInt(targetSeq.MaxValue, 10),
169-
NewValue: "MAXVALUE " + strconv.FormatInt(sourceSeq.MaxValue, 10),
167+
OldValue: fmt.Sprintf("MAXVALUE %d", targetSeq.MaxValue),
168+
NewValue: fmt.Sprintf("MAXVALUE %d", sourceSeq.MaxValue),
170169
})
171170
}
172171
}

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ var isTerminalFunc func(*os.File) bool = func(f *os.File) bool {
119119

120120
// isatty checks if file descriptor is a TTY
121121
func isatty(fd uintptr) bool {
122-
return term.IsTerminal(int(fd))
122+
return term.IsTerminal(int(os.Stdout.Fd()))
123123
}
124124

125125
var rootCmd = &cobra.Command{

0 commit comments

Comments
 (0)