Skip to content

Commit 0919e4c

Browse files
committed
uuid query params
1 parent de30ffb commit 0919e4c

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

internal/params/builder_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,28 @@ func TestBuilder(t *testing.T) {
428428
},
429429
},
430430
},
431+
{
432+
name: xtest.CurrentFileLine(),
433+
builder: Builder{}.
434+
Param("$x").
435+
Uuid([...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}).
436+
Build(),
437+
params: map[string]*Ydb.TypedValue{
438+
"$x": {
439+
Type: &Ydb.Type{
440+
Type: &Ydb.Type_TypeId{
441+
TypeId: Ydb.Type_UUID,
442+
},
443+
},
444+
Value: &Ydb.Value{
445+
Value: &Ydb.Value_Low_128{
446+
Low_128: 651345242494996240,
447+
},
448+
High_128: 72623859790382856,
449+
},
450+
},
451+
},
452+
},
431453
} {
432454
t.Run(tt.name, func(t *testing.T) {
433455
a := allocator.New()

internal/params/optional.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,9 @@ func (p *optional) Yson(v []byte) *optionalBuilder {
152152

153153
return &optionalBuilder{opt: p}
154154
}
155+
156+
func (p *optional) Uuid(v [16]byte) *optionalBuilder {
157+
p.value = value.UUIDValue(v)
158+
159+
return &optionalBuilder{opt: p}
160+
}

internal/params/optional_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,34 @@ func TestOptional(t *testing.T) {
525525
},
526526
},
527527
},
528+
{
529+
name: xtest.CurrentFileLine(),
530+
builder: Builder{}.Param("$x").
531+
Optional().
532+
Uuid([...]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}).
533+
Build(),
534+
params: map[string]*Ydb.TypedValue{
535+
"$x": {
536+
Type: &Ydb.Type{
537+
Type: &Ydb.Type_OptionalType{
538+
OptionalType: &Ydb.OptionalType{
539+
Item: &Ydb.Type{
540+
Type: &Ydb.Type_TypeId{
541+
TypeId: Ydb.Type_UUID,
542+
},
543+
},
544+
},
545+
},
546+
},
547+
Value: &Ydb.Value{
548+
Value: &Ydb.Value_Low_128{
549+
Low_128: 651345242494996240,
550+
},
551+
High_128: 72623859790382856,
552+
},
553+
},
554+
},
555+
},
528556
} {
529557
t.Run(tt.name, func(t *testing.T) {
530558
a := allocator.New()

internal/params/parameters.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,13 @@ func (p *Parameter) Yson(v []byte) Builder {
263263
return p.parent
264264
}
265265

266+
func (p *Parameter) Uuid(v [16]byte) Builder {
267+
p.value = value.UUIDValue(v)
268+
p.parent.params = append(p.parent.params, p)
269+
270+
return p.parent
271+
}
272+
266273
func Declare(p *Parameter) string {
267274
return fmt.Sprintf(
268275
"DECLARE %s AS %s",

0 commit comments

Comments
 (0)