From 3d23de403d07bed45b9b91b0e5e127ed7995c9b5 Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Wed, 23 Oct 2024 15:37:57 +0300 Subject: [PATCH] remove UUID from the ydb params builder --- internal/params/dict.go | 22 +++++++------- internal/params/dict_test.go | 16 ---------- internal/params/list.go | 16 +++++----- internal/params/list_test.go | 16 ---------- internal/params/optional.go | 16 +++++----- internal/params/optional_test.go | 26 ---------------- internal/params/parameters.go | 26 ++++++++-------- internal/params/set.go | 16 +++++----- internal/params/set_test.go | 16 ---------- internal/params/struct.go | 22 +++++++------- internal/params/struct_test.go | 35 --------------------- internal/params/tuple.go | 16 +++++----- internal/params/tuple_test.go | 16 ---------- internal/params/variant_struct.go | 42 +++++++++++++------------- internal/params/variant_struct_test.go | 17 ----------- internal/params/variant_tuple.go | 36 +++++++++++----------- internal/params/variant_tuple_test.go | 17 ----------- 17 files changed, 106 insertions(+), 265 deletions(-) diff --git a/internal/params/dict.go b/internal/params/dict.go index acf253663..67c3f47fa 100644 --- a/internal/params/dict.go +++ b/internal/params/dict.go @@ -444,18 +444,18 @@ func (d *dictValue) YSON(v []byte) *dict { return d.pair.parent } -// UUID has data corruption bug and will be removed in next version. +//// UUID has data corruption bug and will be removed in next version. +//// +//// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (d *dictValue) UUID(v [16]byte) *dict { +// d.pair.parent.values = append(d.pair.parent.values, value.DictValueField{ +// K: d.pair.keyValue, +// V: value.UUIDWithIssue1501Value(v), +// }) // -// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (d *dictValue) UUID(v [16]byte) *dict { - d.pair.parent.values = append(d.pair.parent.values, value.DictValueField{ - K: d.pair.keyValue, - V: value.UUIDWithIssue1501Value(v), - }) - - return d.pair.parent -} +// return d.pair.parent +//} func (d *dictValue) Uuid(v uuid.UUID) *dict { //nolint:revive,stylecheck d.pair.parent.values = append(d.pair.parent.values, value.DictValueField{ diff --git a/internal/params/dict_test.go b/internal/params/dict_test.go index eaa096f90..05b5bc2fa 100644 --- a/internal/params/dict_test.go +++ b/internal/params/dict_test.go @@ -347,22 +347,6 @@ func TestDict(t *testing.T) { }, }, }, - { - method: "UUID", - args: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, - - expected: expected{ - Type: &Ydb.Type{ - Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID}, - }, - Value: &Ydb.Value{ - Value: &Ydb.Value_Low_128{ - Low_128: 651345242494996240, - }, - High_128: 72623859790382856, - }, - }, - }, { method: "Uuid", args: []any{uuid.UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, diff --git a/internal/params/list.go b/internal/params/list.go index 55f42f742..dba0f37e6 100644 --- a/internal/params/list.go +++ b/internal/params/list.go @@ -167,15 +167,15 @@ func (l *listItem) YSON(v []byte) *list { return l.parent } -// UUID has data corruption bug and will be removed in next version. +//// UUID has data corruption bug and will be removed in next version. +//// +//// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (l *listItem) UUID(v [16]byte) *list { +// l.parent.values = append(l.parent.values, value.UUIDWithIssue1501Value(v)) // -// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (l *listItem) UUID(v [16]byte) *list { - l.parent.values = append(l.parent.values, value.UUIDWithIssue1501Value(v)) - - return l.parent -} +// return l.parent +//} func (l *listItem) Uuid(v uuid.UUID) *list { //nolint:revive,stylecheck l.parent.values = append(l.parent.values, value.Uuid(v)) diff --git a/internal/params/list_test.go b/internal/params/list_test.go index e6a771c79..336eb7a53 100644 --- a/internal/params/list_test.go +++ b/internal/params/list_test.go @@ -346,22 +346,6 @@ func TestList(t *testing.T) { }, }, }, - { - method: "UUID", - args: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, - - expected: expected{ - Type: &Ydb.Type{ - Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID}, - }, - Value: &Ydb.Value{ - Value: &Ydb.Value_Low_128{ - Low_128: 651345242494996240, - }, - High_128: 72623859790382856, - }, - }, - }, { method: "Uuid", args: []any{uuid.UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, diff --git a/internal/params/optional.go b/internal/params/optional.go index 1da26925a..cce0f8050 100644 --- a/internal/params/optional.go +++ b/internal/params/optional.go @@ -155,15 +155,15 @@ func (p *optional) YSON(v *[]byte) *optionalBuilder { return &optionalBuilder{opt: p} } -// UUID has data corruption bug and will be removed in next version. +//// UUID has data corruption bug and will be removed in next version. +//// +//// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (p *optional) UUID(v *[16]byte) *optionalBuilder { +// p.value = value.NullableUUIDValue(v) // -// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (p *optional) UUID(v *[16]byte) *optionalBuilder { - p.value = value.NullableUUIDValue(v) - - return &optionalBuilder{opt: p} -} +// return &optionalBuilder{opt: p} +//} func (p *optional) Uuid(v *uuid.UUID) *optionalBuilder { //nolint:revive,stylecheck p.value = value.NullableUuidValue(v) diff --git a/internal/params/optional_test.go b/internal/params/optional_test.go index 72505f336..69aabb2e0 100644 --- a/internal/params/optional_test.go +++ b/internal/params/optional_test.go @@ -555,32 +555,6 @@ func TestOptional(t *testing.T) { }, }, }, - { - method: "UUID", - args: []any{p([...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16})}, - - expected: expected{ - Type: &Ydb.Type{ - Type: &Ydb.Type_OptionalType{ - OptionalType: &Ydb.OptionalType{ - Item: &Ydb.Type{ - Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID}, - }, - }, - }, - }, - Value: &Ydb.Value{ - Value: &Ydb.Value_NestedValue{ - NestedValue: &Ydb.Value{ - Value: &Ydb.Value_Low_128{ - Low_128: 651345242494996240, - }, - High_128: 72623859790382856, - }, - }, - }, - }, - }, { method: "Uuid", args: []any{p(uuid.UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16})}, diff --git a/internal/params/parameters.go b/internal/params/parameters.go index 58b0fc45c..0e089edd5 100644 --- a/internal/params/parameters.go +++ b/internal/params/parameters.go @@ -297,21 +297,21 @@ func (p *Parameter) YSON(v []byte) Builder { return p.parent } -// removed for https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -//func (p *Parameter) UUID(v [16]byte) Builder { -// return p.UUIDWithIssue1501Value(v) +//// removed for https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +////func (p *Parameter) UUID(v [16]byte) Builder { +//// return p.UUIDWithIssue1501Value(v) +////} +// +//// UUIDWithIssue1501Value is field serializer for save data with format bug. +//// For any new code use Uuid +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (p *Parameter) UUIDWithIssue1501Value(v [16]byte) Builder { +// p.value = value.UUIDWithIssue1501Value(v) +// p.parent.params = append(p.parent.params, p) +// +// return p.parent //} -// UUIDWithIssue1501Value is field serializer for save data with format bug. -// For any new code use Uuid -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (p *Parameter) UUIDWithIssue1501Value(v [16]byte) Builder { - p.value = value.UUIDWithIssue1501Value(v) - p.parent.params = append(p.parent.params, p) - - return p.parent -} - func (p *Parameter) Uuid(val uuid.UUID) Builder { //nolint:revive,stylecheck p.value = value.Uuid(val) p.parent.params = append(p.parent.params, p) diff --git a/internal/params/set.go b/internal/params/set.go index 7759f7118..58374b7a2 100644 --- a/internal/params/set.go +++ b/internal/params/set.go @@ -168,15 +168,15 @@ func (s *setItem) YSON(v []byte) *set { return s.parent } -// UUID has data corruption bug and will be removed in next version. +//// UUID has data corruption bug and will be removed in next version. +//// +//// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (s *setItem) UUID(v [16]byte) *set { +// s.parent.values = append(s.parent.values, value.UUIDWithIssue1501Value(v)) // -// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (s *setItem) UUID(v [16]byte) *set { - s.parent.values = append(s.parent.values, value.UUIDWithIssue1501Value(v)) - - return s.parent -} +// return s.parent +//} func (s *setItem) Uuid(v uuid.UUID) *set { //nolint:revive,stylecheck s.parent.values = append(s.parent.values, value.Uuid(v)) diff --git a/internal/params/set_test.go b/internal/params/set_test.go index ceaf1a584..fe35b57e4 100644 --- a/internal/params/set_test.go +++ b/internal/params/set_test.go @@ -346,22 +346,6 @@ func TestSet(t *testing.T) { }, }, }, - { - method: "UUID", - args: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, - - expected: expected{ - Type: &Ydb.Type{ - Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID}, - }, - Value: &Ydb.Value{ - Value: &Ydb.Value_Low_128{ - Low_128: 651345242494996240, - }, - High_128: 72623859790382856, - }, - }, - }, { method: "Uuid", args: []any{uuid.UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, diff --git a/internal/params/struct.go b/internal/params/struct.go index bf70c5eda..8e192cfb9 100644 --- a/internal/params/struct.go +++ b/internal/params/struct.go @@ -233,18 +233,18 @@ func (s *structValue) YSON(v []byte) *structure { return s.parent } -// UUID has data corruption bug and will be removed in next version. +//// UUID has data corruption bug and will be removed in next version. +//// +//// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (s *structValue) UUID(v [16]byte) *structure { +// s.parent.values = append(s.parent.values, value.StructValueField{ +// Name: s.name, +// V: value.UUIDWithIssue1501Value(v), +// }) // -// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (s *structValue) UUID(v [16]byte) *structure { - s.parent.values = append(s.parent.values, value.StructValueField{ - Name: s.name, - V: value.UUIDWithIssue1501Value(v), - }) - - return s.parent -} +// return s.parent +//} func (s *structValue) Uuid(v uuid.UUID) *structure { //nolint:revive,stylecheck s.parent.values = append(s.parent.values, value.StructValueField{ diff --git a/internal/params/struct_test.go b/internal/params/struct_test.go index 10098ab64..b07478d48 100644 --- a/internal/params/struct_test.go +++ b/internal/params/struct_test.go @@ -715,41 +715,6 @@ func TestStruct(t *testing.T) { }, }, }, - { - name: xtest.CurrentFileLine(), - builder: Builder{}.Param("$x").BeginStruct().Field("col1"). - UUID([...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}).EndStruct(), - params: map[string]*Ydb.TypedValue{ - "$x": { - Type: &Ydb.Type{ - Type: &Ydb.Type_StructType{ - StructType: &Ydb.StructType{ - Members: []*Ydb.StructMember{ - { - Name: "col1", - Type: &Ydb.Type{ - Type: &Ydb.Type_TypeId{ - TypeId: Ydb.Type_UUID, - }, - }, - }, - }, - }, - }, - }, - Value: &Ydb.Value{ - Items: []*Ydb.Value{ - { - Value: &Ydb.Value_Low_128{ - Low_128: 651345242494996240, - }, - High_128: 72623859790382856, - }, - }, - }, - }, - }, - }, { name: xtest.CurrentFileLine(), builder: Builder{}.Param("$x").BeginStruct().Field("col1"). diff --git a/internal/params/tuple.go b/internal/params/tuple.go index cc6d75ebd..c4354bcaa 100644 --- a/internal/params/tuple.go +++ b/internal/params/tuple.go @@ -167,15 +167,15 @@ func (t *tupleItem) YSON(v []byte) *tuple { return t.parent } -// UUID has data corruption bug and will be removed in next version. +//// UUID has data corruption bug and will be removed in next version. +//// +//// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (t *tupleItem) UUID(v [16]byte) *tuple { +// t.parent.values = append(t.parent.values, value.UUIDWithIssue1501Value(v)) // -// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (t *tupleItem) UUID(v [16]byte) *tuple { - t.parent.values = append(t.parent.values, value.UUIDWithIssue1501Value(v)) - - return t.parent -} +// return t.parent +//} func (t *tupleItem) Uuid(v uuid.UUID) *tuple { //nolint:revive,stylecheck t.parent.values = append(t.parent.values, value.Uuid(v)) diff --git a/internal/params/tuple_test.go b/internal/params/tuple_test.go index 72811eaa4..18e5a2772 100644 --- a/internal/params/tuple_test.go +++ b/internal/params/tuple_test.go @@ -346,22 +346,6 @@ func TestTuple(t *testing.T) { }, }, }, - { - method: "UUID", - args: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, - - expected: expected{ - Type: &Ydb.Type{ - Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID}, - }, - Value: &Ydb.Value{ - Value: &Ydb.Value_Low_128{ - Low_128: 651345242494996240, - }, - High_128: 72623859790382856, - }, - }, - }, { method: "Uuid", args: []any{uuid.UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, diff --git a/internal/params/variant_struct.go b/internal/params/variant_struct.go index 5ac30e758..8aeff5210 100644 --- a/internal/params/variant_struct.go +++ b/internal/params/variant_struct.go @@ -234,18 +234,18 @@ func (vsf *variantStructField) YSON() *variantStruct { return vsf.parent } -// UUID has data corruption bug and will be removed in next version. +//// UUID has data corruption bug and will be removed in next version. +//// +//// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (vsf *variantStructField) UUID() *variantStruct { +// vsf.parent.fields = append(vsf.parent.fields, types.StructField{ +// Name: vsf.name, +// T: types.UUID, +// }) // -// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (vsf *variantStructField) UUID() *variantStruct { - vsf.parent.fields = append(vsf.parent.fields, types.StructField{ - Name: vsf.name, - T: types.UUID, - }) - - return vsf.parent -} +// return vsf.parent +//} func (vsf *variantStructField) Uuid() *variantStruct { //nolint:revive,stylecheck vsf.parent.fields = append(vsf.parent.fields, types.StructField{ @@ -468,17 +468,17 @@ func (vsi *variantStructItem) YSON(v []byte) *variantStructBuilder { } } -// UUID has data corruption bug and will be removed in next version. +//// UUID has data corruption bug and will be removed in next version. +//// +//// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (vsi *variantStructItem) UUID(v [16]byte) *variantStructBuilder { +// vsi.parent.value = value.UUIDWithIssue1501Value(v) // -// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (vsi *variantStructItem) UUID(v [16]byte) *variantStructBuilder { - vsi.parent.value = value.UUIDWithIssue1501Value(v) - - return &variantStructBuilder{ - parent: vsi.parent, - } -} +// return &variantStructBuilder{ +// parent: vsi.parent, +// } +//} func (vsi *variantStructItem) Uuid(v uuid.UUID) *variantStructBuilder { //nolint:revive,stylecheck vsi.parent.value = value.Uuid(v) diff --git a/internal/params/variant_struct_test.go b/internal/params/variant_struct_test.go index 36a46c951..c461362a0 100644 --- a/internal/params/variant_struct_test.go +++ b/internal/params/variant_struct_test.go @@ -370,23 +370,6 @@ func TestVariantStruct(t *testing.T) { }, }, }, - { - method: "UUID", - itemArgs: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, - - expected: expected{ - Type: &Ydb.Type{ - Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID}, - }, - Value: &Ydb.Value{ - Value: &Ydb.Value_Low_128{ - Low_128: 651345242494996240, - }, - High_128: 72623859790382856, - VariantIndex: 0, - }, - }, - }, { method: "Uuid", itemArgs: []any{uuid.UUID{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, diff --git a/internal/params/variant_tuple.go b/internal/params/variant_tuple.go index 9fb87dcdd..faa9689cb 100644 --- a/internal/params/variant_tuple.go +++ b/internal/params/variant_tuple.go @@ -169,15 +169,15 @@ func (vtt *variantTupleTypes) YSON() *variantTupleTypes { return vtt } -// UUID has data corruption bug and will be removed in next version. +//// UUID has data corruption bug and will be removed in next version. +//// +//// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (vtt *variantTupleTypes) UUID() *variantTupleTypes { +// vtt.tuple.types = append(vtt.tuple.types, types.UUID) // -// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (vtt *variantTupleTypes) UUID() *variantTupleTypes { - vtt.tuple.types = append(vtt.tuple.types, types.UUID) - - return vtt -} +// return vtt +//} func (vtt *variantTupleTypes) Uuid() *variantTupleTypes { //nolint:revive,stylecheck vtt.tuple.types = append(vtt.tuple.types, types.UUID) @@ -385,17 +385,17 @@ func (vti *variantTupleItem) YSON(v []byte) *variantTupleBuilder { } } -// UUID has data corruption bug and will be removed in next version. +//// UUID has data corruption bug and will be removed in next version. +//// +//// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. +//// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 +//func (vti *variantTupleItem) UUID(v [16]byte) *variantTupleBuilder { +// vti.tuple.value = value.UUIDWithIssue1501Value(v) // -// Deprecated: Use Uuid (prefer) or UUIDWithIssue1501Value (for save old behavior) instead. -// https://github.com/ydb-platform/ydb-go-sdk/issues/1501 -func (vti *variantTupleItem) UUID(v [16]byte) *variantTupleBuilder { - vti.tuple.value = value.UUIDWithIssue1501Value(v) - - return &variantTupleBuilder{ - tuple: vti.tuple, - } -} +// return &variantTupleBuilder{ +// tuple: vti.tuple, +// } +//} func (vti *variantTupleItem) Uuid(v uuid.UUID) *variantTupleBuilder { //nolint:revive,stylecheck vti.tuple.value = value.Uuid(v) diff --git a/internal/params/variant_tuple_test.go b/internal/params/variant_tuple_test.go index 3f5676619..c8f894fa8 100644 --- a/internal/params/variant_tuple_test.go +++ b/internal/params/variant_tuple_test.go @@ -369,23 +369,6 @@ func TestVariantTuple(t *testing.T) { }, }, }, - { - method: "UUID", - itemArgs: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}}, - - expected: expected{ - Type: &Ydb.Type{ - Type: &Ydb.Type_TypeId{TypeId: Ydb.Type_UUID}, - }, - Value: &Ydb.Value{ - Value: &Ydb.Value_Low_128{ - Low_128: 651345242494996240, - }, - High_128: 72623859790382856, - VariantIndex: 0, - }, - }, - }, { method: "Uuid", itemArgs: []any{[...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}},