-
Notifications
You must be signed in to change notification settings - Fork 136
Labels
Milestone
Description
Hey, I'm struggling with deserialization.
I'm making a API with Axum that, upon request, can return records from a ScyllaDB based on some criteria and with certain fields. for example I can request records with specific IDs and fields, let's say request to my API would look like
{
"columns": ["id", "action_ts_utc", "name", "description", "for_distribution"],
"keys": [
["some_uuid_here1"],
["some_uuid_here2"],
["some_uuid_here3"],
["some_uuid_here4"]
]
}
And my rust struct look like
#[derive(DeserializeRow)]
pub struct MyTableRow {
pub id: String,
pub action_ts_utc: DateTime<Utc>,
pub joined_ts_utc: DateTime<Utc>,
pub is_active: bool,
pub name: String,
pub description: String,
pub for_distribution: bool,
pub type: String,
}
So my select query would be like
SELECT id, action_ts_utc, name, description, for_distribution FROM myks.mytable WHERE id IN ('some_uuid_here1', 'some_uuid_here2', 'some_uuid_here3', 'some_uuid_here4');
And i will get an error, something like
TypeCheckError: Failed to type check the Rust type myapi::api::handlers::tables::mytable::schema::MyTableRow against CQL column types [Text, Boolean, Uuid, Int, Timestamp] : wrong column count: the statement operates on 5 columns, but the given rust types contains 1%
Types can be different, it's just an example
I understand error, which says that columns I selected doesn't match with struct, and something like following not working too.
#[scylla(flavor = "enforce_order", skip_name_checks)]
Making struct fields optional doesn't working, also as #[scylla(skip)]
So how do i properly handle partial deserialization?