File tree Expand file tree Collapse file tree 3 files changed +22
-16
lines changed
Expand file tree Collapse file tree 3 files changed +22
-16
lines changed Original file line number Diff line number Diff line change 3131 "n" : " int64" ,
3232 "vi" : 64
3333 },
34+ {
35+ "n" : " int64-zero" ,
36+ "vi" : 0
37+ },
38+ {
39+ "n" : " empty-nullint64" ,
40+ "vi" : 0
41+ },
3442 {
3543 "n" : " nullint64" ,
3644 "vi" : 64
Original file line number Diff line number Diff line change @@ -130,18 +130,11 @@ func (t *PageToken) UnmarshalJSON(data []byte) error {
130130 t .cols [i ].Value = nil
131131 case col .ValueAny != nil :
132132 t .cols [i ].Value = col .ValueAny
133-
134- // zero-value checks needed for backward compatibility.
135- // Old format: {"vt": "2023-01-01...", "vu": "00000...", "vi": 0} - all fields are present.
136- // To avoid breaking existing tokens, we need to check for zero value as old logic did.
137- // The next release can drop the 2nd part of the case conditions.
138- case col .ValueTime != nil && ! col .ValueTime .IsZero ():
139- t .cols [i ].Value = * col .ValueTime
140- case col .ValueUUID != nil && * col .ValueUUID != uuid .Nil :
133+ case col .ValueUUID != nil :
141134 t .cols [i ].Value = * col .ValueUUID
142- case col .ValueAny != nil :
143- t .cols [i ].Value = col .ValueAny
144- case col .ValueInt64 != nil && * col . ValueInt64 != 0 :
135+ case col .ValueTime != nil :
136+ t .cols [i ].Value = * col .ValueTime
137+ case col .ValueInt64 != nil :
145138 t .cols [i ].Value = * col .ValueInt64
146139 }
147140 }
Original file line number Diff line number Diff line change @@ -141,6 +141,10 @@ type Column struct {
141141 name string
142142}
143143
144+ func (c Column ) Name () string {
145+ return c .name
146+ }
147+
144148type ColumnConstraint uint8
145149
146150const (
@@ -163,15 +167,16 @@ type Query map[Column]ColumnConstraint
163167func NewQuery () Query { return make (Query ) }
164168
165169func (qc Query ) SetEq (cols ... Column ) Query {
166- for _ , col := range cols {
167- qc [col ] = colConstraintEq
168- }
169- return qc
170+ return qc .set (colConstraintEq , cols ... )
170171}
171172
172173func (qc Query ) SetIsNull (cols ... Column ) Query {
174+ return qc .set (colConstraintIsNull , cols ... )
175+ }
176+
177+ func (qc Query ) set (c ColumnConstraint , cols ... Column ) Query {
173178 for _ , col := range cols {
174- qc [col ] = colConstraintIsNull
179+ qc [col ] = c
175180 }
176181 return qc
177182}
You can’t perform that action at this time.
0 commit comments