bool-rus / ydb-unofficial

Other
2 stars 0 forks source link

error[E0599]: no variant or associated item named `Json` found #4

Closed makorne closed 3 months ago

makorne commented 3 months ago

//use ydb::Value; It works with ydb official

use ydb_unofficial::generated::ydb::value::Value;

let json = Value::Json("{\"id\":\"\",\"name\":\"\"}".to_string());
                            ^^^^ variant or associated item not found in `Value`
error[E0599]: no variant or associated item named `Json` found for enum `ydb_unofficial::generated::ydb::value::Value` in the current scope

How to store json? Thanks!

bool-rus commented 3 months ago

hi) json type not yet implemented.

bool-rus commented 3 months ago

hah, it's already impelmentd in simple ydb (without sqlx) @makorne You need to use TypedValue{type: Json, value: TextValue}

makorne commented 3 months ago

But I cant use this

use ydb_unofficial::generated::ydb::r#type::PrimitiveTypeId::Json;
use ydb_unofficial::generated::ydb::TypedValue;

like

TypedValue{ r#type: Json, value: Some(json_str.to_owned())}

                     mismatched types [E0308] expected `Option<Type>`, found `PrimitiveTypeId`

becouse ydb_unofficial::generated::ydb::Type dont have a Json type:

Enum [ydb_grpc_bindings](https://docs.rs/ydb-grpc-bindings/0.0.1/ydb_grpc_bindings/index.html)::[generated](https://docs.rs/ydb-grpc-bindings/0.0.1/ydb_grpc_bindings/generated/index.html)::[ydb](https://docs.rs/ydb-grpc-bindings/0.0.1/ydb_grpc_bindings/generated/ydb/index.html)::[type](https://docs.rs/ydb-grpc-bindings/0.0.1/ydb_grpc_bindings/generated/ydb/type/index.html)::[Type](https://docs.rs/ydb-grpc-bindings/0.0.1/ydb_grpc_bindings/generated/ydb/type/enum.Type.html#)
[source](https://docs.rs/ydb-grpc-bindings/0.0.1/src/ydb_grpc_bindings/generated/ydb.rs.html#418-450) ·

pub enum Type { TypeId(i32), DecimalType(DecimalType), OptionalType(Box<OptionalType>), ListType(Box<ListType>), TupleType(TupleType), StructType(StructType), DictType(Box<DictType>), VariantType(VariantType), TaggedType(Box<TaggedType>), VoidType(i32), NullType(i32), EmptyListType(i32), EmptyDictType(i32), PgType(PgType), }

Please any example?