File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ package version
55
66import (
77 "bytes"
8+ "database/sql/driver"
89 "fmt"
910 "regexp"
1011 "strconv"
@@ -161,7 +162,7 @@ func (v *Version) Compare(other *Version) int {
161162 // this means Other had the lower specificity
162163 // Check to see if the remaining segments in Self are all zeros -
163164 if ! allZero (segmentsSelf [i :]) {
164- //if not, it means that Self has to be greater than Other
165+ // if not, it means that Self has to be greater than Other
165166 return 1
166167 }
167168 break
@@ -421,3 +422,20 @@ func (v *Version) UnmarshalText(b []byte) error {
421422func (v * Version ) MarshalText () ([]byte , error ) {
422423 return []byte (v .String ()), nil
423424}
425+
426+ // Scan implements the sql.Scanner interface.
427+ func (v * Version ) Scan (src interface {}) error {
428+ switch src := src .(type ) {
429+ case string :
430+ return v .UnmarshalText ([]byte (src ))
431+ case nil :
432+ return nil
433+ default :
434+ return fmt .Errorf ("cannot scan %T as Version" , src )
435+ }
436+ }
437+
438+ // Value implements the driver.Valuer interface.
439+ func (v * Version ) Value () (driver.Value , error ) {
440+ return v .String (), nil
441+ }
You can’t perform that action at this time.
0 commit comments