Skip to content

Commit ad763b6

Browse files
committed
Bump to version 9.0.0
- Update changelog - Remove all references to sqlboiler - Remove all dependencies
1 parent 99fd141 commit ad763b6

22 files changed

+31
-246
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55

6+
## [v9.0.0]
7+
8+
### Added
9+
10+
- Add a new `.Set` that can be introspected to see if things are set.
11+
(thanks @razor-1)
12+
13+
### Fixed
14+
15+
- Fix []byte to be base64 encoded in json to match how []byte is handled
16+
(thanks @razor-1)
17+
618
## [v8.1.2]
719

820
### Fixed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ library in place of `sql.NullXXX`. All types also implement:
1616
### Installation
1717

1818
Null used to be versioned with gopkg.in, so once you upgrade to v8 and beyond
19-
please stop using gopkg.in and ensure you're using `vgo`, `dep` or vendoring to
20-
version null.
19+
please stop using gopkg.in and ensure you're using go modules.
2120

2221
```
23-
go get github.com/volatiletech/null/v8
22+
go get github.com/volatiletech/null/v9
2423
```
2524

2625
### Usage

bool.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"encoding/json"
77
"errors"
88

9-
"github.com/volatiletech/null/v8/convert"
9+
"github.com/volatiletech/null/v9/convert"
1010
)
1111

1212
// Bool is a nullable bool.
@@ -148,14 +148,3 @@ func (b Bool) Value() (driver.Value, error) {
148148
}
149149
return b.Bool, nil
150150
}
151-
152-
// Randomize for sqlboiler
153-
func (b *Bool) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
154-
if shouldBeNull {
155-
b.Bool = false
156-
b.Valid = false
157-
} else {
158-
b.Bool = nextInt()%2 == 1
159-
b.Valid = true
160-
}
161-
}

byte.go

-11
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,3 @@ func (b Byte) Value() (driver.Value, error) {
148148
}
149149
return []byte{b.Byte}, nil
150150
}
151-
152-
// Randomize for sqlboiler
153-
func (b *Byte) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
154-
if shouldBeNull {
155-
b.Byte = byte(0)
156-
b.Valid = false
157-
} else {
158-
b.Byte = byte(nextInt()%60 + 65) // Ascii range
159-
b.Valid = true
160-
}
161-
}

bytes.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"database/sql/driver"
66
"encoding/json"
77

8-
"github.com/volatiletech/null/v8/convert"
8+
"github.com/volatiletech/null/v9/convert"
99
)
1010

1111
// NullBytes is a global byte slice of JSON null
@@ -139,14 +139,3 @@ func (b Bytes) Value() (driver.Value, error) {
139139
}
140140
return b.Bytes, nil
141141
}
142-
143-
// Randomize for sqlboiler
144-
func (b *Bytes) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
145-
if shouldBeNull {
146-
b.Bytes = nil
147-
b.Valid = false
148-
} else {
149-
b.Bytes = []byte{byte(nextInt() % 256)}
150-
b.Valid = true
151-
}
152-
}

float32.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"encoding/json"
77
"strconv"
88

9-
"github.com/volatiletech/null/v8/convert"
9+
"github.com/volatiletech/null/v9/convert"
1010
)
1111

1212
// Float32 is a nullable float32.
@@ -137,14 +137,3 @@ func (f Float32) Value() (driver.Value, error) {
137137
}
138138
return float64(f.Float32), nil
139139
}
140-
141-
// Randomize for sqlboiler
142-
func (f *Float32) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
143-
if shouldBeNull {
144-
f.Float32 = 0
145-
f.Valid = false
146-
} else {
147-
f.Float32 = float32(nextInt()%10)/10.0 + float32(nextInt()%10)
148-
f.Valid = true
149-
}
150-
}

float64.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"encoding/json"
77
"strconv"
88

9-
"github.com/volatiletech/null/v8/convert"
9+
"github.com/volatiletech/null/v9/convert"
1010
)
1111

1212
// Float64 is a nullable float64.
@@ -132,14 +132,3 @@ func (f Float64) Value() (driver.Value, error) {
132132
}
133133
return f.Float64, nil
134134
}
135-
136-
// Randomize for sqlboiler
137-
func (f *Float64) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
138-
if shouldBeNull {
139-
f.Float64 = 0
140-
f.Valid = false
141-
} else {
142-
f.Float64 = float64(nextInt()%10)/10.0 + float64(nextInt()%10)
143-
f.Valid = true
144-
}
145-
}

go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
module github.com/volatiletech/null/v8
1+
module github.com/volatiletech/null/v9
22

33
go 1.14
4-
5-
require github.com/volatiletech/randomize v0.0.1

go.sum

-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +0,0 @@
1-
github.com/friendsofgo/errors v0.9.2 h1:X6NYxef4efCBdwI7BgS820zFaN7Cphrmb+Pljdzjtgk=
2-
github.com/friendsofgo/errors v0.9.2/go.mod h1:yCvFW5AkDIL9qn7suHVLiI/gH228n7PC4Pn44IGoTOI=
3-
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
4-
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
5-
github.com/volatiletech/inflect v0.0.1 h1:2a6FcMQyhmPZcLa+uet3VJ8gLn/9svWhJxJYwvE8KsU=
6-
github.com/volatiletech/inflect v0.0.1/go.mod h1:IBti31tG6phkHitLlr5j7shC5SOo//x0AjDzaJU1PLA=
7-
github.com/volatiletech/randomize v0.0.1 h1:eE5yajattWqTB2/eN8df4dw+8jwAzBtbdo5sbWC4nMk=
8-
github.com/volatiletech/randomize v0.0.1/go.mod h1:GN3U0QYqfZ9FOJ67bzax1cqZ5q2xuj2mXrXBjWaRTlY=
9-
github.com/volatiletech/strmangle v0.0.1 h1:UKQoHmY6be/R3tSvD2nQYrH41k43OJkidwEiC74KIzk=
10-
github.com/volatiletech/strmangle v0.0.1/go.mod h1:F6RA6IkB5vq0yTG4GQ0UsbbRcl3ni9P76i+JrTBKFFg=
11-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
12-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

int.go

+1-13
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import (
44
"bytes"
55
"database/sql/driver"
66
"encoding/json"
7-
"math"
87
"strconv"
98

10-
"github.com/volatiletech/null/v8/convert"
9+
"github.com/volatiletech/null/v9/convert"
1110
)
1211

1312
// Int is an nullable int.
@@ -139,14 +138,3 @@ func (i Int) Value() (driver.Value, error) {
139138
}
140139
return int64(i.Int), nil
141140
}
142-
143-
// Randomize for sqlboiler
144-
func (i *Int) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
145-
if shouldBeNull {
146-
i.Int = 0
147-
i.Valid = false
148-
} else {
149-
i.Int = int(int32(nextInt() % math.MaxInt32))
150-
i.Valid = true
151-
}
152-
}

int16.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"math"
99
"strconv"
1010

11-
"github.com/volatiletech/null/v8/convert"
11+
"github.com/volatiletech/null/v9/convert"
1212
)
1313

1414
// Int16 is an nullable int16.
@@ -141,14 +141,3 @@ func (i Int16) Value() (driver.Value, error) {
141141
}
142142
return int64(i.Int16), nil
143143
}
144-
145-
// Randomize for sqlboiler
146-
func (i *Int16) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
147-
if shouldBeNull {
148-
i.Int16 = 0
149-
i.Valid = false
150-
} else {
151-
i.Int16 = int16(nextInt() % math.MaxInt16)
152-
i.Valid = true
153-
}
154-
}

int32.go

+1-19
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import (
88
"math"
99
"strconv"
1010

11-
"github.com/volatiletech/null/v8/convert"
12-
"github.com/volatiletech/randomize"
11+
"github.com/volatiletech/null/v9/convert"
1312
)
1413

1514
// Int32 is an nullable int32.
@@ -144,20 +143,3 @@ func (i Int32) Value() (driver.Value, error) {
144143
}
145144
return int64(i.Int32), nil
146145
}
147-
148-
// Randomize for sqlboiler
149-
func (i *Int32) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
150-
if shouldBeNull {
151-
i.Int32 = 0
152-
i.Valid = false
153-
} else {
154-
val, ok := randomize.MediumInt(nextInt, fieldType)
155-
if ok {
156-
i.Int32 = val
157-
} else {
158-
i.Int32 = int32(nextInt() % math.MaxInt32)
159-
}
160-
161-
i.Valid = true
162-
}
163-
}

int64.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"encoding/json"
77
"strconv"
88

9-
"github.com/volatiletech/null/v8/convert"
9+
"github.com/volatiletech/null/v9/convert"
1010
)
1111

1212
// Int64 is an nullable int64.
@@ -132,14 +132,3 @@ func (i Int64) Value() (driver.Value, error) {
132132
}
133133
return i.Int64, nil
134134
}
135-
136-
// Randomize for sqlboiler
137-
func (i *Int64) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
138-
if shouldBeNull {
139-
i.Int64 = 0
140-
i.Valid = false
141-
} else {
142-
i.Int64 = int64(nextInt())
143-
i.Valid = true
144-
}
145-
}

int8.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"math"
99
"strconv"
1010

11-
"github.com/volatiletech/null/v8/convert"
11+
"github.com/volatiletech/null/v9/convert"
1212
)
1313

1414
// Int8 is an nullable int8.
@@ -143,14 +143,3 @@ func (i Int8) Value() (driver.Value, error) {
143143
}
144144
return int64(i.Int8), nil
145145
}
146-
147-
// Randomize for sqlboiler
148-
func (i *Int8) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
149-
if shouldBeNull {
150-
i.Int8 = 0
151-
i.Valid = false
152-
} else {
153-
i.Int8 = int8(nextInt() % math.MaxInt8)
154-
i.Valid = true
155-
}
156-
}

json.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import (
77
"errors"
88
"fmt"
99

10-
"github.com/volatiletech/null/v8/convert"
11-
"github.com/volatiletech/randomize"
10+
"github.com/volatiletech/null/v9/convert"
1211
)
1312

1413
// JSON is a nullable []byte that contains JSON.
@@ -189,9 +188,3 @@ func (j JSON) Value() (driver.Value, error) {
189188
}
190189
return j.JSON, nil
191190
}
192-
193-
// Randomize for sqlboiler
194-
func (j *JSON) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
195-
j.JSON = []byte(`"` + randomize.Str(nextInt, 1) + `"`)
196-
j.Valid = true
197-
}

string.go

+1-20
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import (
55
"database/sql/driver"
66
"encoding/json"
77

8-
"github.com/volatiletech/null/v8/convert"
9-
"github.com/volatiletech/randomize"
8+
"github.com/volatiletech/null/v9/convert"
109
)
1110

1211
// String is a nullable string. It supports SQL and JSON serialization.
@@ -132,21 +131,3 @@ func (s String) Value() (driver.Value, error) {
132131
}
133132
return s.String, nil
134133
}
135-
136-
// Randomize for sqlboiler
137-
func (s *String) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
138-
str, ok := randomize.FormattedString(nextInt, fieldType)
139-
if ok {
140-
s.String = str
141-
s.Valid = true
142-
return
143-
}
144-
145-
if shouldBeNull {
146-
s.String = ""
147-
s.Valid = false
148-
} else {
149-
s.String = randomize.Str(nextInt, 1)
150-
s.Valid = true
151-
}
152-
}

time.go

-13
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import (
55
"database/sql/driver"
66
"fmt"
77
"time"
8-
9-
"github.com/volatiletech/randomize"
108
)
119

1210
// Time is a nullable time.Time. It supports SQL and JSON serialization.
@@ -141,14 +139,3 @@ func (t Time) Value() (driver.Value, error) {
141139
}
142140
return t.Time, nil
143141
}
144-
145-
// Randomize for sqlboiler
146-
func (t *Time) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
147-
if shouldBeNull {
148-
t.Time = time.Time{}
149-
t.Valid = false
150-
} else {
151-
t.Time = randomize.Date(nextInt)
152-
t.Valid = true
153-
}
154-
}

uint.go

+1-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"encoding/json"
77
"strconv"
88

9-
"github.com/volatiletech/null/v8/convert"
9+
"github.com/volatiletech/null/v9/convert"
1010
)
1111

1212
// Uint is an nullable uint.
@@ -137,14 +137,3 @@ func (u Uint) Value() (driver.Value, error) {
137137
}
138138
return int64(u.Uint), nil
139139
}
140-
141-
// Randomize for sqlboiler
142-
func (u *Uint) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool) {
143-
if shouldBeNull {
144-
u.Uint = 0
145-
u.Valid = false
146-
} else {
147-
u.Uint = uint(nextInt())
148-
u.Valid = true
149-
}
150-
}

0 commit comments

Comments
 (0)