From 499cdb209edd1cc174cb11dac7cc55c59051d3d7 Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Tue, 14 May 2024 12:52:09 +0300 Subject: [PATCH] Renamed ydb::Value::String -> ydb::Value::Bytes --- Cargo.lock | 2 +- ydb/src/client_table_test_integration.rs | 4 ++-- ydb/src/grpc_wrapper/raw_table_service/value/type.rs | 2 +- .../grpc_wrapper/raw_table_service/value/value_ydb.rs | 4 ++-- ydb/src/types.rs | 9 ++++----- ydb/src/types_converters.rs | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe5e5f1e..d62dde64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2550,7 +2550,7 @@ dependencies = [ [[package]] name = "ydb" -version = "0.8.3" +version = "0.8.4" dependencies = [ "async-trait", "async_once", diff --git a/ydb/src/client_table_test_integration.rs b/ydb/src/client_table_test_integration.rs index dd66a86d..7ba4bdce 100644 --- a/ydb/src/client_table_test_integration.rs +++ b/ydb/src/client_table_test_integration.rs @@ -720,7 +720,7 @@ async fn stream_query() -> YdbResult<()> { vec!["id".to_string(), "val".to_string()], vec![ Value::Int64(*v), - Value::String(Bytes::from(gen_value_by_id(*v))), + Value::Bytes(Bytes::from(gen_value_by_id(*v))), ], )?)) } @@ -798,7 +798,7 @@ FROM match row.remove_field_by_name("val")? { Value::Optional(boxed_val) => match boxed_val.value.unwrap() { - Value::String(content) => { + Value::Bytes(content) => { assert_eq!(gen_value_by_id(expected_id), Vec::::from(content)) } val => panic!("unexpected ydb id type: {:?}", val), diff --git a/ydb/src/grpc_wrapper/raw_table_service/value/type.rs b/ydb/src/grpc_wrapper/raw_table_service/value/type.rs index 29479b32..aa8711b0 100644 --- a/ydb/src/grpc_wrapper/raw_table_service/value/type.rs +++ b/ydb/src/grpc_wrapper/raw_table_service/value/type.rs @@ -159,7 +159,7 @@ impl RawType { t @ RawType::TzDate => return unimplemented_type(t), t@RawType::TzDatetime => return unimplemented_type(t), t@RawType::TzTimestamp => return unimplemented_type(t), - RawType::Bytes => Value::String(Bytes::default()), + RawType::Bytes => Value::Bytes(Bytes::default()), RawType::UTF8 => Value::Text(String::default()), RawType::Yson => Value::Yson(Bytes::default()), RawType::Json => Value::Json(String::default()), diff --git a/ydb/src/grpc_wrapper/raw_table_service/value/value_ydb.rs b/ydb/src/grpc_wrapper/raw_table_service/value/value_ydb.rs index 8d3b1600..aef96e85 100644 --- a/ydb/src/grpc_wrapper/raw_table_service/value/value_ydb.rs +++ b/ydb/src/grpc_wrapper/raw_table_service/value/value_ydb.rs @@ -85,7 +85,7 @@ impl TryFrom for RawTypedValue { r#type: RawType::Interval, value: RawValue::Int64(v.as_nanos()?), }, - Value::String(v) => RawTypedValue { + Value::Bytes(v) => RawTypedValue { r#type: RawType::Bytes, value: RawValue::Bytes(v.into()), }, @@ -230,7 +230,7 @@ impl TryFrom for Value { (t @ RawType::TzDate, _) => return type_unimplemented(t), (t @ RawType::TzDatetime, _) => return type_unimplemented(t), (t @ RawType::TzTimestamp, _) => return type_unimplemented(t), - (RawType::Bytes, RawValue::Bytes(v)) => Value::String(Bytes::from(v)), + (RawType::Bytes, RawValue::Bytes(v)) => Value::Bytes(Bytes::from(v)), (t @ RawType::Bytes, v) => return types_mismatch(t, v), (RawType::UTF8, RawValue::Text(v)) => Value::Text(v), (t @ RawType::UTF8, v) => return types_mismatch(t, v), diff --git a/ydb/src/types.rs b/ydb/src/types.rs index 16029fd6..c803fc27 100644 --- a/ydb/src/types.rs +++ b/ydb/src/types.rs @@ -79,9 +79,8 @@ pub enum Value { Timestamp(std::time::SystemTime), Interval(SignedInterval), - /// Store native bytes array, similary to binary/blob in other databases. It named string by history reason only. - /// Use Utf8 type for store text. - String(Bytes), + // It named String at server, but server String type contains binary data https://ydb.tech/docs/en/yql/reference/types/primitive#string + Bytes(Bytes), /// Text data, encoded to valid utf8 Text(String), @@ -399,7 +398,7 @@ impl Value { ), ), Self::Interval(val) => proto_typed_value(pt::Interval, pv::Int64Value(val.as_nanos()?)), - Self::String(val) => proto_typed_value(pt::String, pv::BytesValue(val.into())), + Self::Bytes(val) => proto_typed_value(pt::String, pv::BytesValue(val.into())), Self::Text(val) => proto_typed_value(pt::Utf8, pv::TextValue(val)), Self::Yson(val) => proto_typed_value(pt::Yson, pv::BytesValue(val.into())), Self::Json(val) => proto_typed_value(pt::Json, pv::TextValue(val)), @@ -529,7 +528,7 @@ impl Value { Value::Null, Value::Bool(false), Value::Bool(true), - Value::String(Bytes::from("asd".to_string())), + Value::Bytes(Bytes::from("asd".to_string())), Value::Text("asd".into()), Value::Text("фыв".into()), Value::Json("{}".into()), diff --git a/ydb/src/types_converters.rs b/ydb/src/types_converters.rs index b0dce1c6..c41ca2b2 100644 --- a/ydb/src/types_converters.rs +++ b/ydb/src/types_converters.rs @@ -93,7 +93,7 @@ simple_convert!( ); simple_convert!( Bytes, - Value::String, + Value::Bytes, Value::Text, Value::Json, Value::JsonDocument,