Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package version

import (
"bytes"
"database/sql/driver"
"fmt"
"reflect"
"regexp"
Expand Down Expand Up @@ -160,7 +161,7 @@ func (v *Version) Compare(other *Version) int {
// this means Other had the lower specificity
// Check to see if the remaining segments in Self are all zeros -
if !allZero(segmentsSelf[i:]) {
//if not, it means that Self has to be greater than Other
// if not, it means that Self has to be greater than Other
return 1
}
break
Expand Down Expand Up @@ -405,3 +406,20 @@ func (v *Version) UnmarshalText(b []byte) error {
func (v *Version) MarshalText() ([]byte, error) {
return []byte(v.String()), nil
}

// Scan implements the sql.Scanner interface.
func (v *Version) Scan(src interface{}) error {
switch src := src.(type) {
case string:
return v.UnmarshalText([]byte(src))
case nil:
return nil
default:
return fmt.Errorf("Cannot scan %T as Version", src)
}
}

// Value implements the driver.Valuer interface.
func (v *Version) Value() (driver.Value, error) {
return v.String(), nil
}