File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ package version
5
5
6
6
import (
7
7
"bytes"
8
+ "database/sql/driver"
8
9
"fmt"
9
10
"regexp"
10
11
"strconv"
@@ -161,7 +162,7 @@ func (v *Version) Compare(other *Version) int {
161
162
// this means Other had the lower specificity
162
163
// Check to see if the remaining segments in Self are all zeros -
163
164
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
165
166
return 1
166
167
}
167
168
break
@@ -421,3 +422,20 @@ func (v *Version) UnmarshalText(b []byte) error {
421
422
func (v * Version ) MarshalText () ([]byte , error ) {
422
423
return []byte (v .String ()), nil
423
424
}
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