Skip to content

Commit ed54b80

Browse files
committed
updated changelog + refactoring
1 parent 4e1deac commit ed54b80

File tree

6 files changed

+229
-228
lines changed

6 files changed

+229
-228
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Added `TzDate`,`TzDateTime`,`TzTimestamp` support for `ydb.ParamsBuilder()`
12
* Changed `List` constructor from `ydb.ParamsBuilder().List().Build().Build()` to `ydb.ParamsBuilder().BeginList().EndList().Build()`
23
* Changed `Set` constructor from `ydb.ParamsBuilder().Set().Build().Build()` to `ydb.ParamsBuilder().BeginSet().EndSet().Build()`
34
* Changed `Dict` constructor from `ydb.ParamsBuilder().Dict().Build().Build()` to `ydb.ParamsBuilder().BeginDict().EndDict().Build()`

internal/params/dict_test.go

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515

1616
func TestDict(t *testing.T) {
1717
type expected struct {
18-
kind *Ydb.Type
19-
value *Ydb.Value
18+
Type *Ydb.Type
19+
Value *Ydb.Value
2020
}
2121

2222
tests := []struct {
@@ -30,10 +30,10 @@ func TestDict(t *testing.T) {
3030
args: []any{uint64(123)},
3131

3232
expected: expected{
33-
kind: &Ydb.Type{
33+
Type: &Ydb.Type{
3434
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UINT64},
3535
},
36-
value: &Ydb.Value{
36+
Value: &Ydb.Value{
3737
Value: &Ydb.Value_Uint64Value{
3838
Uint64Value: 123,
3939
},
@@ -45,10 +45,10 @@ func TestDict(t *testing.T) {
4545
args: []any{int64(123)},
4646

4747
expected: expected{
48-
kind: &Ydb.Type{
48+
Type: &Ydb.Type{
4949
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_INT64},
5050
},
51-
value: &Ydb.Value{
51+
Value: &Ydb.Value{
5252
Value: &Ydb.Value_Int64Value{
5353
Int64Value: 123,
5454
},
@@ -60,10 +60,10 @@ func TestDict(t *testing.T) {
6060
args: []any{uint32(123)},
6161

6262
expected: expected{
63-
kind: &Ydb.Type{
63+
Type: &Ydb.Type{
6464
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UINT32},
6565
},
66-
value: &Ydb.Value{
66+
Value: &Ydb.Value{
6767
Value: &Ydb.Value_Uint32Value{
6868
Uint32Value: 123,
6969
},
@@ -75,10 +75,10 @@ func TestDict(t *testing.T) {
7575
args: []any{int32(123)},
7676

7777
expected: expected{
78-
kind: &Ydb.Type{
78+
Type: &Ydb.Type{
7979
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_INT32},
8080
},
81-
value: &Ydb.Value{
81+
Value: &Ydb.Value{
8282
Value: &Ydb.Value_Int32Value{
8383
Int32Value: 123,
8484
},
@@ -90,10 +90,10 @@ func TestDict(t *testing.T) {
9090
args: []any{uint16(123)},
9191

9292
expected: expected{
93-
kind: &Ydb.Type{
93+
Type: &Ydb.Type{
9494
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UINT16},
9595
},
96-
value: &Ydb.Value{
96+
Value: &Ydb.Value{
9797
Value: &Ydb.Value_Uint32Value{
9898
Uint32Value: 123,
9999
},
@@ -105,10 +105,10 @@ func TestDict(t *testing.T) {
105105
args: []any{int16(123)},
106106

107107
expected: expected{
108-
kind: &Ydb.Type{
108+
Type: &Ydb.Type{
109109
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_INT16},
110110
},
111-
value: &Ydb.Value{
111+
Value: &Ydb.Value{
112112
Value: &Ydb.Value_Int32Value{
113113
Int32Value: 123,
114114
},
@@ -120,10 +120,10 @@ func TestDict(t *testing.T) {
120120
args: []any{uint8(123)},
121121

122122
expected: expected{
123-
kind: &Ydb.Type{
123+
Type: &Ydb.Type{
124124
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UINT8},
125125
},
126-
value: &Ydb.Value{
126+
Value: &Ydb.Value{
127127
Value: &Ydb.Value_Uint32Value{
128128
Uint32Value: 123,
129129
},
@@ -135,10 +135,10 @@ func TestDict(t *testing.T) {
135135
args: []any{int8(123)},
136136

137137
expected: expected{
138-
kind: &Ydb.Type{
138+
Type: &Ydb.Type{
139139
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_INT8},
140140
},
141-
value: &Ydb.Value{
141+
Value: &Ydb.Value{
142142
Value: &Ydb.Value_Int32Value{
143143
Int32Value: 123,
144144
},
@@ -150,10 +150,10 @@ func TestDict(t *testing.T) {
150150
args: []any{true},
151151

152152
expected: expected{
153-
kind: &Ydb.Type{
153+
Type: &Ydb.Type{
154154
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_BOOL},
155155
},
156-
value: &Ydb.Value{
156+
Value: &Ydb.Value{
157157
Value: &Ydb.Value_BoolValue{
158158
BoolValue: true,
159159
},
@@ -165,10 +165,10 @@ func TestDict(t *testing.T) {
165165
args: []any{"test"},
166166

167167
expected: expected{
168-
kind: &Ydb.Type{
168+
Type: &Ydb.Type{
169169
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UTF8},
170170
},
171-
value: &Ydb.Value{
171+
Value: &Ydb.Value{
172172
Value: &Ydb.Value_TextValue{
173173
TextValue: "test",
174174
},
@@ -180,10 +180,10 @@ func TestDict(t *testing.T) {
180180
args: []any{[]byte("test")},
181181

182182
expected: expected{
183-
kind: &Ydb.Type{
183+
Type: &Ydb.Type{
184184
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_STRING},
185185
},
186-
value: &Ydb.Value{
186+
Value: &Ydb.Value{
187187
Value: &Ydb.Value_BytesValue{
188188
BytesValue: []byte("test"),
189189
},
@@ -195,10 +195,10 @@ func TestDict(t *testing.T) {
195195
args: []any{float32(123)},
196196

197197
expected: expected{
198-
kind: &Ydb.Type{
198+
Type: &Ydb.Type{
199199
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_FLOAT},
200200
},
201-
value: &Ydb.Value{
201+
Value: &Ydb.Value{
202202
Value: &Ydb.Value_FloatValue{
203203
FloatValue: float32(123),
204204
},
@@ -210,10 +210,10 @@ func TestDict(t *testing.T) {
210210
args: []any{float64(123)},
211211

212212
expected: expected{
213-
kind: &Ydb.Type{
213+
Type: &Ydb.Type{
214214
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_DOUBLE},
215215
},
216-
value: &Ydb.Value{
216+
Value: &Ydb.Value{
217217
Value: &Ydb.Value_DoubleValue{
218218
DoubleValue: float64(123),
219219
},
@@ -225,10 +225,10 @@ func TestDict(t *testing.T) {
225225
args: []any{time.Second},
226226

227227
expected: expected{
228-
kind: &Ydb.Type{
228+
Type: &Ydb.Type{
229229
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_INTERVAL},
230230
},
231-
value: &Ydb.Value{
231+
Value: &Ydb.Value{
232232
Value: &Ydb.Value_Int64Value{
233233
Int64Value: 1000000,
234234
},
@@ -240,10 +240,10 @@ func TestDict(t *testing.T) {
240240
args: []any{time.Unix(123456789, 456)},
241241

242242
expected: expected{
243-
kind: &Ydb.Type{
243+
Type: &Ydb.Type{
244244
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_DATETIME},
245245
},
246-
value: &Ydb.Value{
246+
Value: &Ydb.Value{
247247
Value: &Ydb.Value_Uint32Value{
248248
Uint32Value: 123456789,
249249
},
@@ -255,10 +255,10 @@ func TestDict(t *testing.T) {
255255
args: []any{time.Unix(123456789, 456)},
256256

257257
expected: expected{
258-
kind: &Ydb.Type{
258+
Type: &Ydb.Type{
259259
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_DATE},
260260
},
261-
value: &Ydb.Value{
261+
Value: &Ydb.Value{
262262
Value: &Ydb.Value_Uint32Value{
263263
Uint32Value: 1428,
264264
},
@@ -270,10 +270,10 @@ func TestDict(t *testing.T) {
270270
args: []any{time.Unix(123456789, 456)},
271271

272272
expected: expected{
273-
kind: &Ydb.Type{
273+
Type: &Ydb.Type{
274274
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_TIMESTAMP},
275275
},
276-
value: &Ydb.Value{
276+
Value: &Ydb.Value{
277277
Value: &Ydb.Value_Uint64Value{
278278
Uint64Value: 123456789000000,
279279
},
@@ -285,15 +285,15 @@ func TestDict(t *testing.T) {
285285
args: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6}, uint32(22), uint32(9)},
286286

287287
expected: expected{
288-
kind: &Ydb.Type{
288+
Type: &Ydb.Type{
289289
Type: &Ydb.Type_DecimalType{
290290
DecimalType: &Ydb.DecimalType{
291291
Precision: 22,
292292
Scale: 9,
293293
},
294294
},
295295
},
296-
value: &Ydb.Value{
296+
Value: &Ydb.Value{
297297
High_128: 72623859790382856,
298298
Value: &Ydb.Value_Low_128{
299299
Low_128: 648519454493508870,
@@ -306,10 +306,10 @@ func TestDict(t *testing.T) {
306306
args: []any{`{"a": 1,"b": "B"}`},
307307

308308
expected: expected{
309-
kind: &Ydb.Type{
309+
Type: &Ydb.Type{
310310
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_JSON},
311311
},
312-
value: &Ydb.Value{
312+
Value: &Ydb.Value{
313313
Value: &Ydb.Value_TextValue{
314314
TextValue: `{"a": 1,"b": "B"}`,
315315
},
@@ -321,10 +321,10 @@ func TestDict(t *testing.T) {
321321
args: []any{`{"a": 1,"b": "B"}`},
322322

323323
expected: expected{
324-
kind: &Ydb.Type{
324+
Type: &Ydb.Type{
325325
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_JSON_DOCUMENT},
326326
},
327-
value: &Ydb.Value{
327+
Value: &Ydb.Value{
328328
Value: &Ydb.Value_TextValue{
329329
TextValue: `{"a": 1,"b": "B"}`,
330330
},
@@ -336,10 +336,10 @@ func TestDict(t *testing.T) {
336336
args: []any{[]byte(`{"a": 1,"b": "B"}`)},
337337

338338
expected: expected{
339-
kind: &Ydb.Type{
339+
Type: &Ydb.Type{
340340
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_YSON},
341341
},
342-
value: &Ydb.Value{
342+
Value: &Ydb.Value{
343343
Value: &Ydb.Value_BytesValue{
344344
BytesValue: []byte(`{"a": 1,"b": "B"}`),
345345
},
@@ -351,10 +351,10 @@ func TestDict(t *testing.T) {
351351
args: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}},
352352

353353
expected: expected{
354-
kind: &Ydb.Type{
354+
Type: &Ydb.Type{
355355
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID},
356356
},
357-
value: &Ydb.Value{
357+
Value: &Ydb.Value{
358358
Value: &Ydb.Value_Low_128{
359359
Low_128: 651345242494996240,
360360
},
@@ -367,10 +367,10 @@ func TestDict(t *testing.T) {
367367
args: []any{time.Unix(123456789, 456).UTC()},
368368

369369
expected: expected{
370-
kind: &Ydb.Type{
370+
Type: &Ydb.Type{
371371
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_TZ_DATETIME},
372372
},
373-
value: &Ydb.Value{
373+
Value: &Ydb.Value{
374374
Value: &Ydb.Value_TextValue{
375375
TextValue: "1973-11-29T21:33:09Z",
376376
},
@@ -382,10 +382,10 @@ func TestDict(t *testing.T) {
382382
args: []any{time.Unix(123456789, 456).UTC()},
383383

384384
expected: expected{
385-
kind: &Ydb.Type{
385+
Type: &Ydb.Type{
386386
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_TZ_DATE},
387387
},
388-
value: &Ydb.Value{
388+
Value: &Ydb.Value{
389389
Value: &Ydb.Value_TextValue{
390390
TextValue: "1973-11-29",
391391
},
@@ -397,10 +397,10 @@ func TestDict(t *testing.T) {
397397
args: []any{time.Unix(123456789, 456).UTC()},
398398

399399
expected: expected{
400-
kind: &Ydb.Type{
400+
Type: &Ydb.Type{
401401
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_TZ_TIMESTAMP},
402402
},
403-
value: &Ydb.Value{
403+
Value: &Ydb.Value{
404404
Value: &Ydb.Value_TextValue{
405405
TextValue: "1973-11-29T21:33:09.000000Z",
406406
},
@@ -430,16 +430,16 @@ func TestDict(t *testing.T) {
430430
Type: &Ydb.Type{
431431
Type: &Ydb.Type_DictType{
432432
DictType: &Ydb.DictType{
433-
Key: key.expected.kind,
434-
Payload: val.expected.kind,
433+
Key: key.expected.Type,
434+
Payload: val.expected.Type,
435435
},
436436
},
437437
},
438438
Value: &Ydb.Value{
439439
Pairs: []*Ydb.ValuePair{
440440
{
441-
Key: key.expected.value,
442-
Payload: val.expected.value,
441+
Key: key.expected.Value,
442+
Payload: val.expected.Value,
443443
},
444444
},
445445
},

0 commit comments

Comments
 (0)