Skip to content

Commit

Permalink
Merge pull request #1525 from ydb-platform/uuid-fix-break
Browse files Browse the repository at this point in the history
uuid-fix-break
  • Loading branch information
rekby authored Oct 23, 2024
2 parents 8e1c411 + 30a789e commit 28e7327
Show file tree
Hide file tree
Showing 18 changed files with 99 additions and 256 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Removed UUID methods from ydb.ParamsBuilder()

## v3.87.0
* BREAK OLD STYLE WORK WITH UUID. See https://github.com/ydb-platform/ydb-go-sdk/issues/1501 for details.
At the version you must explicit choose way for work with uuid: old with bug or new (fixed).
Expand Down
22 changes: 11 additions & 11 deletions internal/params/dict.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
16 changes: 0 additions & 16 deletions internal/params/dict_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand Down
16 changes: 8 additions & 8 deletions internal/params/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
16 changes: 0 additions & 16 deletions internal/params/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand Down
16 changes: 8 additions & 8 deletions internal/params/optional.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 0 additions & 26 deletions internal/params/optional_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})},
Expand Down
8 changes: 4 additions & 4 deletions internal/params/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ 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
Expand Down
16 changes: 8 additions & 8 deletions internal/params/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
16 changes: 0 additions & 16 deletions internal/params/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand Down
22 changes: 11 additions & 11 deletions internal/params/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
35 changes: 0 additions & 35 deletions internal/params/struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down
16 changes: 8 additions & 8 deletions internal/params/tuple.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
16 changes: 0 additions & 16 deletions internal/params/tuple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand Down
Loading

0 comments on commit 28e7327

Please sign in to comment.