File tree 20 files changed +75
-17
lines changed
20 files changed +75
-17
lines changed 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/razor-1 /null/v9 /convert"
10
10
)
11
11
12
12
// Bool is a nullable bool.
@@ -62,6 +62,7 @@ func (b *Bool) UnmarshalJSON(data []byte) error {
62
62
63
63
// UnmarshalText implements encoding.TextUnmarshaler.
64
64
func (b * Bool ) UnmarshalText (text []byte ) error {
65
+ b .set = true
65
66
if text == nil || len (text ) == 0 {
66
67
b .Valid = false
67
68
return nil
@@ -107,6 +108,7 @@ func (b Bool) MarshalText() ([]byte, error) {
107
108
func (b * Bool ) SetValid (v bool ) {
108
109
b .Bool = v
109
110
b .Valid = true
111
+ b .set = true
110
112
}
111
113
112
114
// Ptr returns a pointer to this Bool's value, or a nil pointer if this Bool is null.
@@ -124,6 +126,7 @@ func (b Bool) IsZero() bool {
124
126
125
127
// Scan implements the Scanner interface.
126
128
func (b * Bool ) Scan (value interface {}) error {
129
+ b .set = true
127
130
if value == nil {
128
131
b .Bool , b .Valid = false , false
129
132
return nil
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ func (b *Byte) UnmarshalJSON(data []byte) error {
66
66
67
67
// UnmarshalText implements encoding.TextUnmarshaler.
68
68
func (b * Byte ) UnmarshalText (text []byte ) error {
69
+ b .set = true
69
70
if text == nil || len (text ) == 0 {
70
71
b .Valid = false
71
72
return nil
@@ -100,6 +101,7 @@ func (b Byte) MarshalText() ([]byte, error) {
100
101
func (b * Byte ) SetValid (n byte ) {
101
102
b .Byte = n
102
103
b .Valid = true
104
+ b .set = true
103
105
}
104
106
105
107
// Ptr returns a pointer to this Byte's value, or a nil pointer if this Byte is null.
@@ -117,6 +119,7 @@ func (b Byte) IsZero() bool {
117
119
118
120
// Scan implements the Scanner interface.
119
121
func (b * Byte ) Scan (value interface {}) error {
122
+ b .set = true
120
123
if value == nil {
121
124
b .Byte , b .Valid = 0 , false
122
125
return nil
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/razor-1 /null/v9 /convert"
9
9
)
10
10
11
11
// NullBytes is a global byte slice of JSON null
@@ -67,6 +67,7 @@ func (b *Bytes) UnmarshalJSON(data []byte) error {
67
67
68
68
// UnmarshalText implements encoding.TextUnmarshaler.
69
69
func (b * Bytes ) UnmarshalText (text []byte ) error {
70
+ b .set = true
70
71
if len (text ) == 0 {
71
72
b .Bytes = nil
72
73
b .Valid = false
@@ -98,6 +99,7 @@ func (b Bytes) MarshalText() ([]byte, error) {
98
99
func (b * Bytes ) SetValid (n []byte ) {
99
100
b .Bytes = n
100
101
b .Valid = true
102
+ b .set = true
101
103
}
102
104
103
105
// Ptr returns a pointer to this Bytes's value, or a nil pointer if this Bytes is null.
@@ -115,6 +117,7 @@ func (b Bytes) IsZero() bool {
115
117
116
118
// Scan implements the Scanner interface.
117
119
func (b * Bytes ) Scan (value interface {}) error {
120
+ b .set = true
118
121
if value == nil {
119
122
b .Bytes , b .Valid = []byte {}, false
120
123
return nil
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/razor-1 /null/v9 /convert"
10
10
)
11
11
12
12
// Float32 is a nullable float32.
@@ -63,6 +63,7 @@ func (f *Float32) UnmarshalJSON(data []byte) error {
63
63
64
64
// UnmarshalText implements encoding.TextUnmarshaler.
65
65
func (f * Float32 ) UnmarshalText (text []byte ) error {
66
+ f .set = true
66
67
if text == nil || len (text ) == 0 {
67
68
f .Valid = false
68
69
return nil
@@ -96,6 +97,7 @@ func (f Float32) MarshalText() ([]byte, error) {
96
97
func (f * Float32 ) SetValid (n float32 ) {
97
98
f .Float32 = n
98
99
f .Valid = true
100
+ f .set = true
99
101
}
100
102
101
103
// Ptr returns a pointer to this Float32's value, or a nil pointer if this Float32 is null.
@@ -113,6 +115,7 @@ func (f Float32) IsZero() bool {
113
115
114
116
// Scan implements the Scanner interface.
115
117
func (f * Float32 ) Scan (value interface {}) error {
118
+ f .set = true
116
119
if value == nil {
117
120
f .Float32 , f .Valid = 0 , false
118
121
return nil
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/razor-1 /null/v9 /convert"
10
10
)
11
11
12
12
// Float64 is a nullable float64.
@@ -61,6 +61,7 @@ func (f *Float64) UnmarshalJSON(data []byte) error {
61
61
62
62
// UnmarshalText implements encoding.TextUnmarshaler.
63
63
func (f * Float64 ) UnmarshalText (text []byte ) error {
64
+ f .set = true
64
65
if text == nil || len (text ) == 0 {
65
66
f .Valid = false
66
67
return nil
@@ -91,6 +92,7 @@ func (f Float64) MarshalText() ([]byte, error) {
91
92
func (f * Float64 ) SetValid (n float64 ) {
92
93
f .Float64 = n
93
94
f .Valid = true
95
+ f .set = true
94
96
}
95
97
96
98
// Ptr returns a pointer to this Float64's value, or a nil pointer if this Float64 is null.
@@ -108,6 +110,7 @@ func (f Float64) IsZero() bool {
108
110
109
111
// Scan implements the Scanner interface.
110
112
func (f * Float64 ) Scan (value interface {}) error {
113
+ f .set = true
111
114
if value == nil {
112
115
f .Float64 , f .Valid = 0 , false
113
116
return nil
Original file line number Diff line number Diff line change @@ -2,4 +2,6 @@ module github.com/razor-1/null/v9
2
2
3
3
go 1.14
4
4
5
- require github.com/volatiletech/randomize v0.0.1
5
+ require (
6
+ github.com/volatiletech/randomize v0.0.1
7
+ )
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4
4
4
github.com/gofrs/uuid v3.2.0+incompatible /go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM =
5
5
github.com/volatiletech/inflect v0.0.1 h1:2a6FcMQyhmPZcLa+uet3VJ8gLn/9svWhJxJYwvE8KsU =
6
6
github.com/volatiletech/inflect v0.0.1 /go.mod h1:IBti31tG6phkHitLlr5j7shC5SOo//x0AjDzaJU1PLA =
7
+ github.com/volatiletech/null/v8 v8.1.0 h1:eAO3I31A5R04usY5SKMMfDcOCnEGyT/T4wRI0JVGp4U =
8
+ github.com/volatiletech/null/v8 v8.1.0 /go.mod h1:98DbwNoKEpRrYtGjWFctievIfm4n4MxG0A6EBUcoS5g =
7
9
github.com/volatiletech/randomize v0.0.1 h1:eE5yajattWqTB2/eN8df4dw+8jwAzBtbdo5sbWC4nMk =
8
10
github.com/volatiletech/randomize v0.0.1 /go.mod h1:GN3U0QYqfZ9FOJ67bzax1cqZ5q2xuj2mXrXBjWaRTlY =
9
11
github.com/volatiletech/strmangle v0.0.1 h1:UKQoHmY6be/R3tSvD2nQYrH41k43OJkidwEiC74KIzk =
Original file line number Diff line number Diff line change 7
7
"math"
8
8
"strconv"
9
9
10
- "github.com/volatiletech /null/v8 /convert"
10
+ "github.com/razor-1 /null/v9 /convert"
11
11
)
12
12
13
13
// Int is an nullable int.
@@ -65,6 +65,7 @@ func (i *Int) UnmarshalJSON(data []byte) error {
65
65
66
66
// UnmarshalText implements encoding.TextUnmarshaler.
67
67
func (i * Int ) UnmarshalText (text []byte ) error {
68
+ i .set = true
68
69
if text == nil || len (text ) == 0 {
69
70
i .Valid = false
70
71
return nil
@@ -98,6 +99,7 @@ func (i Int) MarshalText() ([]byte, error) {
98
99
func (i * Int ) SetValid (n int ) {
99
100
i .Int = n
100
101
i .Valid = true
102
+ i .set = true
101
103
}
102
104
103
105
// Ptr returns a pointer to this Int's value, or a nil pointer if this Int is null.
@@ -115,6 +117,7 @@ func (i Int) IsZero() bool {
115
117
116
118
// Scan implements the Scanner interface.
117
119
func (i * Int ) Scan (value interface {}) error {
120
+ i .set = true
118
121
if value == nil {
119
122
i .Int , i .Valid = 0 , false
120
123
return nil
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/razor-1 /null/v9 /convert"
12
12
)
13
13
14
14
// Int16 is an nullable int16.
@@ -69,6 +69,7 @@ func (i *Int16) UnmarshalJSON(data []byte) error {
69
69
70
70
// UnmarshalText implements encoding.TextUnmarshaler.
71
71
func (i * Int16 ) UnmarshalText (text []byte ) error {
72
+ i .set = true
72
73
if text == nil || len (text ) == 0 {
73
74
i .Valid = false
74
75
return nil
@@ -102,6 +103,7 @@ func (i Int16) MarshalText() ([]byte, error) {
102
103
func (i * Int16 ) SetValid (n int16 ) {
103
104
i .Int16 = n
104
105
i .Valid = true
106
+ i .set = true
105
107
}
106
108
107
109
// Ptr returns a pointer to this Int16's value, or a nil pointer if this Int16 is null.
@@ -119,6 +121,7 @@ func (i Int16) IsZero() bool {
119
121
120
122
// Scan implements the Scanner interface.
121
123
func (i * Int16 ) Scan (value interface {}) error {
124
+ i .set = true
122
125
if value == nil {
123
126
i .Int16 , i .Valid = 0 , false
124
127
return nil
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/razor-1 /null/v9 /convert"
12
12
"github.com/volatiletech/randomize"
13
13
)
14
14
@@ -70,6 +70,7 @@ func (i *Int32) UnmarshalJSON(data []byte) error {
70
70
71
71
// UnmarshalText implements encoding.TextUnmarshaler.
72
72
func (i * Int32 ) UnmarshalText (text []byte ) error {
73
+ i .set = true
73
74
if text == nil || len (text ) == 0 {
74
75
i .Valid = false
75
76
return nil
@@ -103,6 +104,7 @@ func (i Int32) MarshalText() ([]byte, error) {
103
104
func (i * Int32 ) SetValid (n int32 ) {
104
105
i .Int32 = n
105
106
i .Valid = true
107
+ i .set = true
106
108
}
107
109
108
110
// Ptr returns a pointer to this Int32's value, or a nil pointer if this Int32 is null.
@@ -120,6 +122,7 @@ func (i Int32) IsZero() bool {
120
122
121
123
// Scan implements the Scanner interface.
122
124
func (i * Int32 ) Scan (value interface {}) error {
125
+ i .set = true
123
126
if value == nil {
124
127
i .Int32 , i .Valid = 0 , false
125
128
return nil
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/razor-1 /null/v9 /convert"
10
10
)
11
11
12
12
// Int64 is an nullable int64.
@@ -61,6 +61,7 @@ func (i *Int64) UnmarshalJSON(data []byte) error {
61
61
62
62
// UnmarshalText implements encoding.TextUnmarshaler.
63
63
func (i * Int64 ) UnmarshalText (text []byte ) error {
64
+ i .set = true
64
65
if text == nil || len (text ) == 0 {
65
66
i .Valid = false
66
67
return nil
@@ -91,6 +92,7 @@ func (i Int64) MarshalText() ([]byte, error) {
91
92
func (i * Int64 ) SetValid (n int64 ) {
92
93
i .Int64 = n
93
94
i .Valid = true
95
+ i .set = true
94
96
}
95
97
96
98
// Ptr returns a pointer to this Int64's value, or a nil pointer if this Int64 is null.
@@ -108,6 +110,7 @@ func (i Int64) IsZero() bool {
108
110
109
111
// Scan implements the Scanner interface.
110
112
func (i * Int64 ) Scan (value interface {}) error {
113
+ i .set = true
111
114
if value == nil {
112
115
i .Int64 , i .Valid = 0 , false
113
116
return nil
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/razor-1 /null/v9 /convert"
12
12
)
13
13
14
14
// Int8 is an nullable int8.
@@ -69,6 +69,7 @@ func (i *Int8) UnmarshalJSON(data []byte) error {
69
69
70
70
// UnmarshalText implements encoding.TextUnmarshaler.
71
71
func (i * Int8 ) UnmarshalText (text []byte ) error {
72
+ i .set = true
72
73
if text == nil || len (text ) == 0 {
73
74
i .Valid = false
74
75
return nil
@@ -102,6 +103,7 @@ func (i Int8) MarshalText() ([]byte, error) {
102
103
func (i * Int8 ) SetValid (n int8 ) {
103
104
i .Int8 = n
104
105
i .Valid = true
106
+ i .set = true
105
107
}
106
108
107
109
// Ptr returns a pointer to this Int8's value, or a nil pointer if this Int8 is null.
@@ -119,6 +121,7 @@ func (i Int8) IsZero() bool {
119
121
120
122
// Scan implements the Scanner interface.
121
123
func (i * Int8 ) Scan (value interface {}) error {
124
+ i .set = true
122
125
if value == nil {
123
126
i .Int8 , i .Valid = 0 , false
124
127
return nil
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"
10
+ "github.com/razor-1 /null/v9 /convert"
11
11
"github.com/volatiletech/randomize"
12
12
)
13
13
@@ -86,6 +86,7 @@ func (j *JSON) UnmarshalJSON(data []byte) error {
86
86
87
87
// UnmarshalText implements encoding.TextUnmarshaler.
88
88
func (j * JSON ) UnmarshalText (text []byte ) error {
89
+ j .set = true
89
90
if text == nil || len (text ) == 0 {
90
91
j .JSON = nil
91
92
j .Valid = false
@@ -131,6 +132,7 @@ func (j JSON) MarshalText() ([]byte, error) {
131
132
func (j * JSON ) SetValid (n []byte ) {
132
133
j .JSON = n
133
134
j .Valid = true
135
+ j .set = true
134
136
}
135
137
136
138
// Ptr returns a pointer to this JSON's value, or a nil pointer if this JSON is null.
@@ -148,6 +150,7 @@ func (j JSON) IsZero() bool {
148
150
149
151
// Scan implements the Scanner interface.
150
152
func (j * JSON ) Scan (value interface {}) error {
153
+ j .set = true
151
154
if value == nil {
152
155
j .JSON , j .Valid = []byte {}, false
153
156
return nil
You can’t perform that action at this time.
0 commit comments