ClickHouse / ClickHouse/clickhouse-rs
`Query::param` should not accept `impl serde::Serialize` (breaking)
- Dominant language
- Rust
- Stars
- 559
- Forks
- 172
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 3
Description
Consider this example
```rs
use serde::Deserialize;
use clickhouse::{Client, Row, error::Result};
#[tokio::main]
async fn main() -> Result<()> {
let client = Client::default().with_url("http://localhost:8123");
#[derive(Debug, Deserialize, Row)]
struct MyRow {
#[serde(with = "clickhouse::serde::chrono::datetime")]
dt: chrono::DateTime,
}
let dt = chrono::DateTime::parse_from_rfc3339("2024-01-02T15:04:05Z").unwrap().with_timezone(&chrono::Utc);
let r = client.query(
"
SELECT {dt:DateTime} AS dt
",
)
.with_option("date_time_input_format", "best_effort")
.param("dt", dt)
.fetch_all::().await?;
}
```
which fails with:
```
Error: BadResponse("Code: 457. DB::Exception:
Value 2024-01-02T15:04:05Z cannot be parsed as DateTime for query parameter 'dt' because it isn't parsed completely:
only 19 of 20 bytes was parsed: 2024-01-02T15:04:05. (BAD_QUERY_PARAMETER)
```
It should work seamlessly for the user, and perhaps we need to introduce a `ClickHouseParam` trait, and/or some kinds of wrappers.
Contributor guide
Assessment
This issue has not been assessed yet.