suharev7 / clickhouse-rs

Asynchronous ClickHouse client library for Rust programming language.
MIT License
324 stars 121 forks source link

Is array of string is still supported? #177

Closed MBoui closed 2 years ago

MBoui commented 2 years ago

I have this code:

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Session {
    pub title: String,
    pub tags: Vec<String>,

}

impl RowBuilder for Session {
    fn apply<K: ColumnType>(
        self,
        block: &mut Block<K>,
    ) -> std::result::Result<(), clickhouse_rs::errors::Error> {
        block.push(row! {
          title: self.title,
          tags: self.tags,
        })?;
        Ok(())
   }
}

Unfortunately, that generate this error:

the trait bound `clickhouse_rs::types::Value: std::convert::From<Vec<std::string::String>>` is not satisfied

I was pretty sure that the Array of String is supported. Is it still true with the async-await branch?

suharev7 commented 2 years ago

I've pushed support array of string for row macro.

MBoui commented 2 years ago

Thanks!

MBoui commented 2 years ago

Re-open it because now i got this error:

Server error: `Input/output error: `From SQL error: `SqlType::Array(String) cannot be cast to Nullable(String).```

The logs

2022-07-16T06:54:28.591771Z  INFO clickhouse_rs: [ping]
2022-07-16T06:54:28.593231Z  INFO sqlx::query: /* SQLx ping */; rows affected: 0, rows returned: 0, elapsed: 757.972µs
2022-07-16T06:54:28.599659Z  INFO clickhouse_rs: [pong]
2022-07-16T06:54:28.599807Z  INFO clickhouse_rs: [insert]     INSERT INTO stats (`title`, `tags`) VALUES
MBoui commented 2 years ago

nvm, my state was broken. All goods! Thanks again!