Skip to content

Commit 74f2ece

Browse files
authored
Merge branch 'master' into fix-1506-optional-in-params
2 parents 4264123 + 9f8e82e commit 74f2ece

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1775
-355
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
* Fixed send optional arguments to the server with `ydb.ParamsBuilder`
22

3+
## v3.87.0
4+
* BREAK OLD STYLE WORK WITH UUID. See https://github.com/ydb-platform/ydb-go-sdk/issues/1501 for details.
5+
At the version you must explicit choose way for work with uuid: old with bug or new (fixed).
6+
7+
## v3.86.1
8+
* Fixed scan to optional uuid
9+
10+
## v3.86.0
11+
* Add workaround for bug in uuid send/receive from server. It is migration version. All native code and most database sql code worked with uuid continue to work.
12+
Dedicated version for migrate code for workaround/fix uuid bug. See https://github.com/ydb-platform/ydb-go-sdk/issues/1501 for details.
13+
14+
## v3.85.3
15+
* Renamed `query.WithPoolID()` into `query.WithResourcePool()`
16+
17+
## v3.85.2
18+
* Added experimental `query.WithPoolID()` execute option for define resource pool for execute query
19+
20+
## v3.85.1
21+
* Added `spans.Retry` constructor of `trace.Retry`
322

423
## v3.85.0
524
* Added experimental package `spans` with tracing adapter interfaces for OpenTelemetry, OpenTracing, etc.

examples/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ require (
5151
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
5252
github.com/syndtr/goleveldb v1.0.0 // indirect
5353
github.com/yandex-cloud/go-genproto v0.0.0-20220815090733-4c139c0154e2 // indirect
54-
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240920120314-0fed943b0136 // indirect
54+
github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b // indirect
5555
github.com/ydb-platform/ydb-go-yc-metadata v0.6.1 // indirect
5656
golang.org/x/crypto v0.24.0 // indirect
5757
golang.org/x/mod v0.17.0 // indirect

examples/go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,10 +1840,8 @@ github.com/ydb-platform/gorm-driver v0.1.3 h1:uewwScbRuCixNPC0LF7gDKvWcB13/iLj76
18401840
github.com/ydb-platform/gorm-driver v0.1.3/go.mod h1:49cSoG5J18muQTiKj4StL2dHs1/dB94OitnHOvetK24=
18411841
github.com/ydb-platform/xorm v0.0.3 h1:MXk42lANB6r/MMLg/XdJfyXJycGUDlCeLiMlLGDKVPw=
18421842
github.com/ydb-platform/xorm v0.0.3/go.mod h1:hFsU7EUF0o3S+l5c0eyP2yPVjJ0d4gsFdqCsyazzwBc=
1843-
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240528144234-5d5a685e41f7 h1:nL8XwD6fSst7xFUirkaWJmE7kM0CdWRYgu6+YQer1d4=
1844-
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240528144234-5d5a685e41f7/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I=
1845-
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240920120314-0fed943b0136 h1:MO32/Cba3XpNYWcoz3y13eHZG+RzDHmFPry3ren6BmE=
1846-
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240920120314-0fed943b0136/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I=
1843+
github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b h1:8yiv/W+1xTdifJh1Stkck0gFJjys9kg0/r86Buljuss=
1844+
github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I=
18471845
github.com/ydb-platform/ydb-go-sdk-auth-environ v0.3.0 h1:JxSvw+Moont8qCmibP2MjSEIHfkWJLkw0fHZemAk+d0=
18481846
github.com/ydb-platform/ydb-go-sdk-auth-environ v0.3.0/go.mod h1:YzCPoNrTbrXZg9bO2YkbjI6eQLkaRIE9Bq8ponu0g8A=
18491847
github.com/ydb-platform/ydb-go-sdk-prometheus/v2 v2.0.1 h1:Lsir3AC2VQOTlp8UjZY9zQdCVfWvBNHT3hZn+jSGoo0=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/golang-jwt/jwt/v4 v4.4.1
77
github.com/google/uuid v1.6.0
88
github.com/jonboulle/clockwork v0.3.0
9-
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240920120314-0fed943b0136
9+
github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b
1010
golang.org/x/net v0.23.0
1111
golang.org/x/sync v0.6.0
1212
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
6565
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
6666
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
6767
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
68-
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240920120314-0fed943b0136 h1:MO32/Cba3XpNYWcoz3y13eHZG+RzDHmFPry3ren6BmE=
69-
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240920120314-0fed943b0136/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I=
68+
github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b h1:8yiv/W+1xTdifJh1Stkck0gFJjys9kg0/r86Buljuss=
69+
github.com/ydb-platform/ydb-go-genproto v0.0.0-20241022174402-dd276c7f197b/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I=
7070
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
7171
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
7272
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=

internal/bind/params.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"sort"
1010
"time"
1111

12+
"github.com/google/uuid"
13+
1214
"github.com/ydb-platform/ydb-go-sdk/v3/internal/params"
1315
"github.com/ydb-platform/ydb-go-sdk/v3/internal/value"
1416
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
@@ -113,9 +115,22 @@ func toValue(v interface{}) (_ types.Value, err error) {
113115

114116
return types.ListValue(items...), nil
115117
case [16]byte:
116-
return types.UUIDValue(x), nil
118+
return nil, xerrors.Wrap(value.ErrIssue1501BadUUID)
117119
case *[16]byte:
118-
return types.NullableUUIDValue(x), nil
120+
return nil, xerrors.Wrap(value.ErrIssue1501BadUUID)
121+
case types.UUIDBytesWithIssue1501Type:
122+
return types.UUIDWithIssue1501Value(x.AsBytesArray()), nil
123+
case *types.UUIDBytesWithIssue1501Type:
124+
if x == nil {
125+
return types.NullableUUIDValueWithIssue1501(nil), nil
126+
}
127+
val := x.AsBytesArray()
128+
129+
return types.NullableUUIDValueWithIssue1501(&val), nil
130+
case uuid.UUID:
131+
return types.UuidValue(x), nil
132+
case *uuid.UUID:
133+
return types.NullableUUIDTypedValue(x), nil
119134
case time.Time:
120135
return types.TimestampValueFromTime(x), nil
121136
case *time.Time:

internal/bind/params_test.go

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import (
77
"testing"
88
"time"
99

10+
"github.com/google/uuid"
1011
"github.com/stretchr/testify/require"
1112

1213
"github.com/ydb-platform/ydb-go-sdk/v3/internal/params"
14+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/value"
1315
"github.com/ydb-platform/ydb-go-sdk/v3/table"
1416
"github.com/ydb-platform/ydb-go-sdk/v3/table/types"
1517
)
@@ -277,23 +279,38 @@ func TestToValue(t *testing.T) {
277279
dst: types.ListValue(types.TextValue("test")),
278280
err: nil,
279281
},
280-
281282
{
282283
src: [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
283-
dst: types.UUIDValue([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}),
284-
err: nil,
284+
dst: nil,
285+
err: types.ErrIssue1501BadUUID,
286+
},
287+
{
288+
src: func() *[16]byte { return nil }(),
289+
dst: nil,
290+
err: types.ErrIssue1501BadUUID,
285291
},
286292
{
287293
src: func(v [16]byte) *[16]byte { return &v }([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}),
288-
dst: types.OptionalValue(types.UUIDValue([16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16})),
294+
dst: nil,
295+
err: types.ErrIssue1501BadUUID,
296+
},
297+
{
298+
src: uuid.UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16},
299+
dst: value.TextValue("01020304-0506-0708-090a-0b0c0d0e0f10"),
289300
err: nil,
290301
},
291302
{
292-
src: func() *[16]byte { return nil }(),
293-
dst: types.NullValue(types.TypeUUID),
303+
src: func(v uuid.UUID) *uuid.UUID { return &v }(uuid.UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}),
304+
// uuid implemented driver.Valuer and doesn't set optional wrapper
305+
dst: types.TextValue("01020304-0506-0708-090a-0b0c0d0e0f10"),
294306
err: nil,
295307
},
296-
308+
// https://github.com/ydb-platform/ydb-go-sdk/issues/1515
309+
//{
310+
// src: func() *uuid.UUID { return nil }(),
311+
// dst: nil,
312+
// err: nil,
313+
//},
297314
{
298315
src: time.Unix(42, 43),
299316
dst: types.TimestampValueFromTime(time.Unix(42, 43)),

internal/params/builder_test.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -345,22 +345,6 @@ func TestBuilder(t *testing.T) {
345345
},
346346
},
347347
},
348-
{
349-
method: "UUID",
350-
args: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}},
351-
352-
expected: expected{
353-
Type: &Ydb.Type{
354-
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID},
355-
},
356-
Value: &Ydb.Value{
357-
Value: &Ydb.Value_Low_128{
358-
Low_128: 651345242494996240,
359-
},
360-
High_128: 72623859790382856,
361-
},
362-
},
363-
},
364348
{
365349
method: "TzDatetime",
366350
args: []any{time.Unix(123456789, 456).UTC()},

internal/params/dict.go

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package params
33
import (
44
"time"
55

6+
"github.com/google/uuid"
7+
68
"github.com/ydb-platform/ydb-go-sdk/v3/internal/value"
79
)
810

@@ -201,8 +203,28 @@ func (d *dictPair) YSON(v []byte) *dictValue {
201203
}
202204
}
203205

206+
// UUID has data corruption bug and will be removed in next version.
207+
//
208+
// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead.
209+
// https://github.com/ydb-platform/ydb-go-sdk/issues/1501
204210
func (d *dictPair) UUID(v [16]byte) *dictValue {
205-
d.keyValue = value.UUIDValue(v)
211+
d.keyValue = value.UUIDWithIssue1501Value(v)
212+
213+
return &dictValue{
214+
pair: d,
215+
}
216+
}
217+
218+
func (d *dictPair) Uuid(v uuid.UUID) *dictValue { //nolint:revive,stylecheck
219+
d.keyValue = value.Uuid(v)
220+
221+
return &dictValue{
222+
pair: d,
223+
}
224+
}
225+
226+
func (d *dictPair) UUIDWithIssue1501Value(v [16]byte) *dictValue {
227+
d.keyValue = value.UUIDWithIssue1501Value(v)
206228

207229
return &dictValue{
208230
pair: d,
@@ -422,10 +444,32 @@ func (d *dictValue) YSON(v []byte) *dict {
422444
return d.pair.parent
423445
}
424446

447+
// UUID has data corruption bug and will be removed in next version.
448+
//
449+
// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead.
450+
// https://github.com/ydb-platform/ydb-go-sdk/issues/1501
425451
func (d *dictValue) UUID(v [16]byte) *dict {
426452
d.pair.parent.values = append(d.pair.parent.values, value.DictValueField{
427453
K: d.pair.keyValue,
428-
V: value.UUIDValue(v),
454+
V: value.UUIDWithIssue1501Value(v),
455+
})
456+
457+
return d.pair.parent
458+
}
459+
460+
func (d *dictValue) Uuid(v uuid.UUID) *dict { //nolint:revive,stylecheck
461+
d.pair.parent.values = append(d.pair.parent.values, value.DictValueField{
462+
K: d.pair.keyValue,
463+
V: value.Uuid(v),
464+
})
465+
466+
return d.pair.parent
467+
}
468+
469+
func (d *dictValue) UUIDWithIssue1501Value(v [16]byte) *dict {
470+
d.pair.parent.values = append(d.pair.parent.values, value.DictValueField{
471+
K: d.pair.keyValue,
472+
V: value.UUIDWithIssue1501Value(v),
429473
})
430474

431475
return d.pair.parent

internal/params/dict_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66
"time"
77

8+
"github.com/google/uuid"
89
"github.com/stretchr/testify/require"
910
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb"
1011

@@ -362,6 +363,38 @@ func TestDict(t *testing.T) {
362363
},
363364
},
364365
},
366+
{
367+
method: "Uuid",
368+
args: []any{uuid.UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}},
369+
370+
expected: expected{
371+
Type: &Ydb.Type{
372+
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID},
373+
},
374+
Value: &Ydb.Value{
375+
Value: &Ydb.Value_Low_128{
376+
Low_128: 506660481424032516,
377+
},
378+
High_128: 1157159078456920585,
379+
},
380+
},
381+
},
382+
{
383+
method: "UUIDWithIssue1501Value",
384+
args: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}},
385+
386+
expected: expected{
387+
Type: &Ydb.Type{
388+
Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID},
389+
},
390+
Value: &Ydb.Value{
391+
Value: &Ydb.Value_Low_128{
392+
Low_128: 651345242494996240,
393+
},
394+
High_128: 72623859790382856,
395+
},
396+
},
397+
},
365398
{
366399
method: "TzDatetime",
367400
args: []any{time.Unix(123456789, 456).UTC()},

0 commit comments

Comments
 (0)