File tree 22 files changed +31
-246
lines changed
22 files changed +31
-246
lines changed Original file line number Diff line number Diff line change 3
3
The format is based on [ Keep a Changelog] ( http://keepachangelog.com/en/1.0.0/ )
4
4
and this project adheres to [ Semantic Versioning] ( http://semver.org/spec/v2.0.0.html ) .
5
5
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
+
6
18
## [ v8.1.2]
7
19
8
20
### Fixed
Original file line number Diff line number Diff line change @@ -16,11 +16,10 @@ library in place of `sql.NullXXX`. All types also implement:
16
16
### Installation
17
17
18
18
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.
21
20
22
21
```
23
- go get github.com/volatiletech/null/v8
22
+ go get github.com/volatiletech/null/v9
24
23
```
25
24
26
25
### Usage
Original file line number Diff line number Diff line change 6
6
"encoding/json"
7
7
"errors"
8
8
9
- "github.com/volatiletech/null/v8 /convert"
9
+ "github.com/volatiletech/null/v9 /convert"
10
10
)
11
11
12
12
// Bool is a nullable bool.
@@ -148,14 +148,3 @@ func (b Bool) Value() (driver.Value, error) {
148
148
}
149
149
return b .Bool , nil
150
150
}
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
- }
Original file line number Diff line number Diff line change @@ -148,14 +148,3 @@ func (b Byte) Value() (driver.Value, error) {
148
148
}
149
149
return []byte {b .Byte }, nil
150
150
}
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
- }
Original file line number Diff line number Diff line change 5
5
"database/sql/driver"
6
6
"encoding/json"
7
7
8
- "github.com/volatiletech/null/v8 /convert"
8
+ "github.com/volatiletech/null/v9 /convert"
9
9
)
10
10
11
11
// NullBytes is a global byte slice of JSON null
@@ -139,14 +139,3 @@ func (b Bytes) Value() (driver.Value, error) {
139
139
}
140
140
return b .Bytes , nil
141
141
}
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
- }
Original file line number Diff line number Diff line change 6
6
"encoding/json"
7
7
"strconv"
8
8
9
- "github.com/volatiletech/null/v8 /convert"
9
+ "github.com/volatiletech/null/v9 /convert"
10
10
)
11
11
12
12
// Float32 is a nullable float32.
@@ -137,14 +137,3 @@ func (f Float32) Value() (driver.Value, error) {
137
137
}
138
138
return float64 (f .Float32 ), nil
139
139
}
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
- }
Original file line number Diff line number Diff line change 6
6
"encoding/json"
7
7
"strconv"
8
8
9
- "github.com/volatiletech/null/v8 /convert"
9
+ "github.com/volatiletech/null/v9 /convert"
10
10
)
11
11
12
12
// Float64 is a nullable float64.
@@ -132,14 +132,3 @@ func (f Float64) Value() (driver.Value, error) {
132
132
}
133
133
return f .Float64 , nil
134
134
}
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
- }
Original file line number Diff line number Diff line change 1
- module github.com/volatiletech/null/v8
1
+ module github.com/volatiletech/null/v9
2
2
3
3
go 1.14
4
-
5
- require github.com/volatiletech/randomize v0.0.1
Original file line number Diff line number Diff line change 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 =
Original file line number Diff line number Diff line change @@ -4,10 +4,9 @@ import (
4
4
"bytes"
5
5
"database/sql/driver"
6
6
"encoding/json"
7
- "math"
8
7
"strconv"
9
8
10
- "github.com/volatiletech/null/v8 /convert"
9
+ "github.com/volatiletech/null/v9 /convert"
11
10
)
12
11
13
12
// Int is an nullable int.
@@ -139,14 +138,3 @@ func (i Int) Value() (driver.Value, error) {
139
138
}
140
139
return int64 (i .Int ), nil
141
140
}
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
- }
Original file line number Diff line number Diff line change 8
8
"math"
9
9
"strconv"
10
10
11
- "github.com/volatiletech/null/v8 /convert"
11
+ "github.com/volatiletech/null/v9 /convert"
12
12
)
13
13
14
14
// Int16 is an nullable int16.
@@ -141,14 +141,3 @@ func (i Int16) Value() (driver.Value, error) {
141
141
}
142
142
return int64 (i .Int16 ), nil
143
143
}
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
- }
Original file line number Diff line number Diff line change 8
8
"math"
9
9
"strconv"
10
10
11
- "github.com/volatiletech/null/v8/convert"
12
- "github.com/volatiletech/randomize"
11
+ "github.com/volatiletech/null/v9/convert"
13
12
)
14
13
15
14
// Int32 is an nullable int32.
@@ -144,20 +143,3 @@ func (i Int32) Value() (driver.Value, error) {
144
143
}
145
144
return int64 (i .Int32 ), nil
146
145
}
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
- }
Original file line number Diff line number Diff line change 6
6
"encoding/json"
7
7
"strconv"
8
8
9
- "github.com/volatiletech/null/v8 /convert"
9
+ "github.com/volatiletech/null/v9 /convert"
10
10
)
11
11
12
12
// Int64 is an nullable int64.
@@ -132,14 +132,3 @@ func (i Int64) Value() (driver.Value, error) {
132
132
}
133
133
return i .Int64 , nil
134
134
}
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
- }
Original file line number Diff line number Diff line change 8
8
"math"
9
9
"strconv"
10
10
11
- "github.com/volatiletech/null/v8 /convert"
11
+ "github.com/volatiletech/null/v9 /convert"
12
12
)
13
13
14
14
// Int8 is an nullable int8.
@@ -143,14 +143,3 @@ func (i Int8) Value() (driver.Value, error) {
143
143
}
144
144
return int64 (i .Int8 ), nil
145
145
}
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
- }
Original file line number Diff line number Diff line change 7
7
"errors"
8
8
"fmt"
9
9
10
- "github.com/volatiletech/null/v8/convert"
11
- "github.com/volatiletech/randomize"
10
+ "github.com/volatiletech/null/v9/convert"
12
11
)
13
12
14
13
// JSON is a nullable []byte that contains JSON.
@@ -189,9 +188,3 @@ func (j JSON) Value() (driver.Value, error) {
189
188
}
190
189
return j .JSON , nil
191
190
}
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
- }
Original file line number Diff line number Diff line change 5
5
"database/sql/driver"
6
6
"encoding/json"
7
7
8
- "github.com/volatiletech/null/v8/convert"
9
- "github.com/volatiletech/randomize"
8
+ "github.com/volatiletech/null/v9/convert"
10
9
)
11
10
12
11
// String is a nullable string. It supports SQL and JSON serialization.
@@ -132,21 +131,3 @@ func (s String) Value() (driver.Value, error) {
132
131
}
133
132
return s .String , nil
134
133
}
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
- }
Original file line number Diff line number Diff line change 5
5
"database/sql/driver"
6
6
"fmt"
7
7
"time"
8
-
9
- "github.com/volatiletech/randomize"
10
8
)
11
9
12
10
// Time is a nullable time.Time. It supports SQL and JSON serialization.
@@ -141,14 +139,3 @@ func (t Time) Value() (driver.Value, error) {
141
139
}
142
140
return t .Time , nil
143
141
}
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
- }
Original file line number Diff line number Diff line change 6
6
"encoding/json"
7
7
"strconv"
8
8
9
- "github.com/volatiletech/null/v8 /convert"
9
+ "github.com/volatiletech/null/v9 /convert"
10
10
)
11
11
12
12
// Uint is an nullable uint.
@@ -137,14 +137,3 @@ func (u Uint) Value() (driver.Value, error) {
137
137
}
138
138
return int64 (u .Uint ), nil
139
139
}
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
- }
You can’t perform that action at this time.
0 commit comments