@@ -15,6 +15,7 @@ import (
1515 "github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
1616 "github.com/ydb-platform/ydb-go-sdk/v3/internal/decimal"
1717 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
18+ "github.com/ydb-platform/ydb-go-sdk/v3/internal/xstring"
1819)
1920
2021type Value interface {
@@ -122,7 +123,7 @@ func primitiveValueFromYDB(t PrimitiveType, v *Ydb.Value) (Value, error) {
122123 case TypeYSON :
123124 switch vv := v .GetValue ().(type ) {
124125 case * Ydb.Value_TextValue :
125- return YSONValue ([] byte (vv .TextValue )), nil
126+ return YSONValue (xstring . ToBytes (vv .TextValue )), nil
126127 case * Ydb.Value_BytesValue :
127128 return YSONValue (vv .BytesValue ), nil
128129 default :
@@ -579,7 +580,7 @@ func (v *doubleValue) castTo(dst interface{}) error {
579580 * vv = strconv .FormatFloat (v .value , 'f' , - 1 , 64 )
580581 return nil
581582 case * []byte :
582- * vv = [] byte (strconv .FormatFloat (v .value , 'f' , - 1 , 64 ))
583+ * vv = xstring . ToBytes (strconv .FormatFloat (v .value , 'f' , - 1 , 64 ))
583584 return nil
584585 case * float64 :
585586 * vv = v .value
@@ -621,7 +622,7 @@ func (v dyNumberValue) castTo(dst interface{}) error {
621622 * vv = string (v )
622623 return nil
623624 case * []byte :
624- * vv = [] byte ( v )
625+ * vv = xstring . ToBytes ( string ( v ) )
625626 return nil
626627 default :
627628 return xerrors .WithStackTrace (fmt .Errorf ("cannot cast '%+v' (type '%s') to '%T' destination" , v , v .Type ().Yql (), vv ))
@@ -660,7 +661,7 @@ func (v *floatValue) castTo(dst interface{}) error {
660661 * vv = strconv .FormatFloat (float64 (v .value ), 'f' , - 1 , 32 )
661662 return nil
662663 case * []byte :
663- * vv = [] byte (strconv .FormatFloat (float64 (v .value ), 'f' , - 1 , 32 ))
664+ * vv = xstring . ToBytes (strconv .FormatFloat (float64 (v .value ), 'f' , - 1 , 32 ))
664665 return nil
665666 case * float64 :
666667 * vv = float64 (v .value )
@@ -705,7 +706,7 @@ func (v int8Value) castTo(dst interface{}) error {
705706 * vv = strconv .FormatInt (int64 (v ), 10 )
706707 return nil
707708 case * []byte :
708- * vv = [] byte (strconv .FormatInt (int64 (v ), 10 ))
709+ * vv = xstring . ToBytes (strconv .FormatInt (int64 (v ), 10 ))
709710 return nil
710711 case * int64 :
711712 * vv = int64 (v )
@@ -760,7 +761,7 @@ func (v int16Value) castTo(dst interface{}) error {
760761 * vv = strconv .FormatInt (int64 (v ), 10 )
761762 return nil
762763 case * []byte :
763- * vv = [] byte (strconv .FormatInt (int64 (v ), 10 ))
764+ * vv = xstring . ToBytes (strconv .FormatInt (int64 (v ), 10 ))
764765 return nil
765766 case * int64 :
766767 * vv = int64 (v )
@@ -812,7 +813,7 @@ func (v int32Value) castTo(dst interface{}) error {
812813 * vv = strconv .FormatInt (int64 (v ), 10 )
813814 return nil
814815 case * []byte :
815- * vv = [] byte (strconv .FormatInt (int64 (v ), 10 ))
816+ * vv = xstring . ToBytes (strconv .FormatInt (int64 (v ), 10 ))
816817 return nil
817818 case * int64 :
818819 * vv = int64 (v )
@@ -864,7 +865,7 @@ func (v int64Value) castTo(dst interface{}) error {
864865 * vv = strconv .FormatInt (int64 (v ), 10 )
865866 return nil
866867 case * []byte :
867- * vv = [] byte (strconv .FormatInt (int64 (v ), 10 ))
868+ * vv = xstring . ToBytes (strconv .FormatInt (int64 (v ), 10 ))
868869 return nil
869870 case * int64 :
870871 * vv = int64 (v )
@@ -985,7 +986,7 @@ func (v jsonValue) castTo(dst interface{}) error {
985986 * vv = string (v )
986987 return nil
987988 case * []byte :
988- * vv = [] byte ( v )
989+ * vv = xstring . ToBytes ( string ( v ) )
989990 return nil
990991 default :
991992 return xerrors .WithStackTrace (fmt .Errorf ("cannot cast '%+v' (type '%s') to '%T' destination" , v , v .Type ().Yql (), vv ))
@@ -1022,7 +1023,7 @@ func (v jsonDocumentValue) castTo(dst interface{}) error {
10221023 * vv = string (v )
10231024 return nil
10241025 case * []byte :
1025- * vv = [] byte ( v )
1026+ * vv = xstring . ToBytes ( string ( v ) )
10261027 return nil
10271028 default :
10281029 return xerrors .WithStackTrace (fmt .Errorf ("cannot cast '%+v' (type '%s') to '%T' destination" , v , v .Type ().Yql (), vv ))
@@ -1401,7 +1402,7 @@ func (v tzDateValue) castTo(dst interface{}) error {
14011402 * vv = string (v )
14021403 return nil
14031404 case * []byte :
1404- * vv = [] byte ( v )
1405+ * vv = xstring . ToBytes ( string ( v ) )
14051406 return nil
14061407 default :
14071408 return xerrors .WithStackTrace (fmt .Errorf ("cannot cast '%+v' (type '%s') to '%T' destination" , v , v .Type ().Yql (), vv ))
@@ -1442,7 +1443,7 @@ func (v tzDatetimeValue) castTo(dst interface{}) error {
14421443 * vv = string (v )
14431444 return nil
14441445 case * []byte :
1445- * vv = [] byte ( v )
1446+ * vv = xstring . ToBytes ( string ( v ) )
14461447 return nil
14471448 default :
14481449 return xerrors .WithStackTrace (fmt .Errorf ("cannot cast '%+v' (type '%s') to '%T' destination" , v , v .Type ().Yql (), vv ))
@@ -1483,7 +1484,7 @@ func (v tzTimestampValue) castTo(dst interface{}) error {
14831484 * vv = string (v )
14841485 return nil
14851486 case * []byte :
1486- * vv = [] byte ( v )
1487+ * vv = xstring . ToBytes ( string ( v ) )
14871488 return nil
14881489 default :
14891490 return xerrors .WithStackTrace (fmt .Errorf ("cannot cast '%+v' (type '%s') to '%T' destination" , v , v .Type ().Yql (), vv ))
@@ -1524,7 +1525,7 @@ func (v uint8Value) castTo(dst interface{}) error {
15241525 * vv = strconv .FormatInt (int64 (v ), 10 )
15251526 return nil
15261527 case * []byte :
1527- * vv = [] byte (strconv .FormatInt (int64 (v ), 10 ))
1528+ * vv = xstring . ToBytes (strconv .FormatInt (int64 (v ), 10 ))
15281529 return nil
15291530 case * uint64 :
15301531 * vv = uint64 (v )
@@ -1588,7 +1589,7 @@ func (v uint16Value) castTo(dst interface{}) error {
15881589 * vv = strconv .FormatInt (int64 (v ), 10 )
15891590 return nil
15901591 case * []byte :
1591- * vv = [] byte (strconv .FormatInt (int64 (v ), 10 ))
1592+ * vv = xstring . ToBytes (strconv .FormatInt (int64 (v ), 10 ))
15921593 return nil
15931594 case * uint64 :
15941595 * vv = uint64 (v )
@@ -1646,7 +1647,7 @@ func (v uint32Value) castTo(dst interface{}) error {
16461647 * vv = strconv .FormatInt (int64 (v ), 10 )
16471648 return nil
16481649 case * []byte :
1649- * vv = [] byte (strconv .FormatInt (int64 (v ), 10 ))
1650+ * vv = xstring . ToBytes (strconv .FormatInt (int64 (v ), 10 ))
16501651 return nil
16511652 case * uint64 :
16521653 * vv = uint64 (v )
@@ -1695,7 +1696,7 @@ func (v uint64Value) castTo(dst interface{}) error {
16951696 * vv = strconv .FormatInt (int64 (v ), 10 )
16961697 return nil
16971698 case * []byte :
1698- * vv = [] byte (strconv .FormatInt (int64 (v ), 10 ))
1699+ * vv = xstring . ToBytes (strconv .FormatInt (int64 (v ), 10 ))
16991700 return nil
17001701 case * uint64 :
17011702 * vv = uint64 (v )
@@ -1735,7 +1736,7 @@ func (v textValue) castTo(dst interface{}) error {
17351736 * vv = string (v )
17361737 return nil
17371738 case * []byte :
1738- * vv = [] byte ( v )
1739+ * vv = xstring . ToBytes ( string ( v ) )
17391740 return nil
17401741 default :
17411742 return xerrors .WithStackTrace (fmt .Errorf ("cannot cast '%+v' (type '%s') to '%T' destination" , v , v .Type ().Yql (), vv ))
@@ -1947,7 +1948,7 @@ type ysonValue []byte
19471948func (v ysonValue ) castTo (dst interface {}) error {
19481949 switch vv := dst .(type ) {
19491950 case * string :
1950- * vv = string (v )
1951+ * vv = xstring . FromBytes (v )
19511952 return nil
19521953 case * []byte :
19531954 * vv = v
@@ -2122,7 +2123,7 @@ type bytesValue []byte
21222123func (v bytesValue ) castTo (dst interface {}) error {
21232124 switch vv := dst .(type ) {
21242125 case * string :
2125- * vv = string (v )
2126+ * vv = xstring . FromBytes (v )
21262127 return nil
21272128 case * []byte :
21282129 * vv = v
0 commit comments