Skip to content

Commit

Permalink
Fix issue with interface selection in serialization (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
irees authored Oct 20, 2023
1 parent 721ba03 commit 86d52ee
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions tl/tt/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func NewBool(v bool) Bool {
return Bool{Valid: true, Val: v}
}

func (r *Bool) String() string {
func (r Bool) String() string {
return ""
}

Expand Down Expand Up @@ -67,7 +67,7 @@ func (r *Bool) UnmarshalJSON(v []byte) error {
return r.Scan(string(stripQuotes(v)))
}

func (r *Bool) MarshalJSON() ([]byte, error) {
func (r Bool) MarshalJSON() ([]byte, error) {
if !r.Valid {
return jsonNull(), nil
}
Expand Down
8 changes: 4 additions & 4 deletions tl/tt/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ func NewDate(v time.Time) Date {
return Date{Valid: true, Val: v}
}

func (r *Date) IsZero() bool {
func (r Date) IsZero() bool {
return !r.Valid
}

func (r *Date) Before(other Date) bool {
func (r Date) Before(other Date) bool {
return r.Val.Before(other.Val)
}

func (r *Date) After(other Date) bool {
func (r Date) After(other Date) bool {
return r.Val.After(other.Val)
}

func (r *Date) String() string {
func (r Date) String() string {
if !r.Valid {
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion tl/tt/float.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (r *Float) Scan(src interface{}) error {
return err
}

func (r *Float) String() string {
func (r Float) String() string {
if r.Val > -100_000 && r.Val < 100_000 {
return fmt.Sprintf("%g", r.Val)
}
Expand Down
2 changes: 1 addition & 1 deletion tl/tt/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ func NewInt(v int) Int {
}

// Int is a convenience function for int(v)
func (r *Int) Int() int {
func (r Int) Int() int {
return int(r.Val)
}
2 changes: 1 addition & 1 deletion tl/tt/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func NewKey(v string) Key {
return Key{Option[string]{Valid: true, Val: v}}
}

func (r *Key) Int() int {
func (r Key) Int() int {
a, _ := strconv.Atoi(r.Val)
return a
}
4 changes: 2 additions & 2 deletions tl/tt/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Tags struct {
}

// Keys return the tag keys
func (r *Tags) Keys() []string {
func (r Tags) Keys() []string {
var ret []string
for k := range r.tags {
ret = append(ret, k)
Expand All @@ -31,7 +31,7 @@ func (r *Tags) Set(k, v string) {
}

// Get a tag value by key
func (r *Tags) Get(k string) (string, bool) {
func (r Tags) Get(k string) (string, bool) {
if r.tags == nil {
return "", false
}
Expand Down
4 changes: 2 additions & 2 deletions tl/tt/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ func NewTime(v time.Time) Time {
}

// IsZero returns if this is a zero value.
func (r *Time) IsZero() bool {
func (r Time) IsZero() bool {
return !r.Valid
}

func (r *Time) String() string {
func (r Time) String() string {
if !r.Valid {
return ""
}
Expand Down
4 changes: 2 additions & 2 deletions tl/tt/widetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewWideTimeFromSeconds(value int) WideTime {
return wt
}

func (wt *WideTime) String() string {
func (wt WideTime) String() string {
if !wt.Valid {
return ""
}
Expand All @@ -42,7 +42,7 @@ func (wt WideTime) Value() (driver.Value, error) {
return int64(wt.Seconds), nil
}

func (wt *WideTime) ToCsv() string {
func (wt WideTime) ToCsv() string {
return wt.String()
}

Expand Down

0 comments on commit 86d52ee

Please sign in to comment.