Protryon / klickhouse

Rust crate for accessing Clickhouse

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Q] Might it possible to rename columns?

ablearthy opened this issue · comments

Like that

#[derive(Row, Debug, Default)]
pub struct MyUserData {
   #[serde(rename = "Id")]
   id: Uuid,
   #[serde(rename = "UserData")]
   user_data: String,
   #[serde(rename = "CreatedAt")]
   created_at: DateTime,
}

Yes.
Currently it's implemented as:

#[derive(Row, Debug, Default)]
pub struct MyUserData {
   #[klickhouse(rename = "Id")]
   id: Uuid,
   #[klickhouse(rename = "UserData")]
   user_data: String,
   #[klickhouse(rename = "CreatedAt")]
   created_at: DateTime,
}

It's implemented this way so that one can derive both serde and klickhouse without conflicts.

Will add to docs.