Skip to content

Commit

Permalink
Merge pull request #198 from ydb-platform/rename-string
Browse files Browse the repository at this point in the history
Renamed ydb::Value::String -> ydb::Value::Bytes
  • Loading branch information
rekby authored May 14, 2024
2 parents 6cdf51b + 499cdb2 commit 1afcd5b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ydb/src/client_table_test_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
],
)?))
}
Expand Down Expand Up @@ -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::<u8>::from(content))
}
val => panic!("unexpected ydb id type: {:?}", val),
Expand Down
2 changes: 1 addition & 1 deletion ydb/src/grpc_wrapper/raw_table_service/value/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
4 changes: 2 additions & 2 deletions ydb/src/grpc_wrapper/raw_table_service/value/value_ydb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl TryFrom<crate::Value> 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()),
},
Expand Down Expand Up @@ -230,7 +230,7 @@ impl TryFrom<RawTypedValue> 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),
Expand Down
9 changes: 4 additions & 5 deletions ydb/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion ydb/src/types_converters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ simple_convert!(
);
simple_convert!(
Bytes,
Value::String,
Value::Bytes,
Value::Text,
Value::Json,
Value::JsonDocument,
Expand Down

0 comments on commit 1afcd5b

Please sign in to comment.