Skip to content

Commit 52a8e84

Browse files
authored
refactor: rename derive to macros (#318)
1 parent 8538255 commit 52a8e84

30 files changed

+38
-39
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- run: rustup override set nightly
6060
- run: rustup show active-toolchain -v
6161
# Serde 1.0.227 fails to build with `--cfg docsrs`, only pass it to our own packages
62-
- run: cargo rustdoc -p clickhouse-derive --all-features -- -D warnings --cfg docsrs
62+
- run: cargo rustdoc -p clickhouse-macros --all-features -- -D warnings --cfg docsrs
6363
- run: cargo rustdoc -p clickhouse-types --all-features -- -D warnings --cfg docsrs
6464
- run: cargo rustdoc -p clickhouse --all-features -- -D warnings --cfg docsrs
6565

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3737
- tls: improved error messages in case of missing TLS features when using HTTPS ([#229]).
3838
- crate: MSRV is now 1.79 due to borrowed rows support redesign in [#247].
3939
- crate: bumped dependencies, see [#232], [#239] and [#280] for additional details.
40+
- crate: starting from 0.3.0, `clickhouse-derive` is now published as [`clickhouse-macros` on crates.io](https://crates.io/crates/clickhouse-macros/0.3.0). The former `clickhouse-derive` crate is discontinued. ([#318]).
4041

4142
### Added
4243

@@ -73,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7374
[#280]: https://github.com/ClickHouse/clickhouse-rs/pull/280
7475
[#292]: https://github.com/ClickHouse/clickhouse-rs/pull/292
7576
[#311]: https://github.com/ClickHouse/clickhouse-rs/pull/311
77+
[#318]: https://github.com/ClickHouse/clickhouse-rs/pull/318
7678

7779
## [0.13.3] - 2025-05-29
7880
### Added

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ edition.workspace = true
1212
rust-version.workspace = true
1313

1414
[workspace]
15-
members = ["derive", "types"]
15+
members = ["macros", "types"]
1616
# `rust-version`-aware dependency resolution;
1717
# applies to all workspace members
1818
resolver = "3"
@@ -122,7 +122,7 @@ rustls-tls-native-roots = [
122122
]
123123

124124
[dependencies]
125-
clickhouse-derive = { version = "0.3.0", path = "derive" }
125+
clickhouse-macros = { version = "0.3.0", path = "macros" }
126126
clickhouse-types = { version = "0.1.0", path = "types" }
127127

128128
thiserror = "2.0"
@@ -155,7 +155,7 @@ quanta = { version = "0.12", optional = true }
155155
replace_with = { version = "0.1.7" }
156156

157157
[dev-dependencies]
158-
clickhouse-derive = { version = "0.3.0", path = "derive" }
158+
clickhouse-macros = { version = "0.3.0", path = "macros" }
159159
criterion = "0.6"
160160
serde = { version = "1.0.106", features = ["derive"] }
161161
tokio = { version = "1.0.1", features = ["full", "test-util"] }

examples/clickhouse_cloud.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clickhouse::Client;
2+
use clickhouse::Row;
23
use clickhouse::sql::Identifier;
3-
use clickhouse_derive::Row;
44
use serde::{Deserialize, Serialize};
55
use std::env;
66

@@ -42,9 +42,9 @@ async fn main() -> clickhouse::error::Result<()> {
4242
.execute()
4343
.await?;
4444

45-
let mut insert = client.insert::<Data>(table_name).await?;
45+
let mut insert = client.insert::<MyRow>(table_name).await?;
4646
insert
47-
.write(&Data {
47+
.write(&MyRow {
4848
id: 42,
4949
name: "foo".into(),
5050
})
@@ -57,15 +57,15 @@ async fn main() -> clickhouse::error::Result<()> {
5757
// This setting is optional; use it when you need strong consistency guarantees on the reads
5858
// See https://clickhouse.com/docs/en/cloud/reference/shared-merge-tree#consistency
5959
.with_option("select_sequential_consistency", "1")
60-
.fetch_all::<Data>()
60+
.fetch_all::<MyRow>()
6161
.await?;
6262

6363
println!("Stored data: {data:?}");
6464
Ok(())
6565
}
6666

6767
#[derive(Debug, Serialize, Deserialize, Row)]
68-
struct Data {
68+
struct MyRow {
6969
id: i32,
7070
name: String,
7171
}

examples/data_types_derive_containers.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ async fn main() -> Result<()> {
3737
.execute()
3838
.await?;
3939

40-
let mut insert = client.insert::<Row>(table_name).await?;
41-
insert.write(&Row::new()).await?;
40+
let mut insert = client.insert::<MyRow>(table_name).await?;
41+
insert.write(&MyRow::new()).await?;
4242
insert.end().await?;
4343

4444
let rows = client
4545
.query("SELECT ?fields FROM ?")
4646
.bind(Identifier(table_name))
47-
.fetch_all::<Row>()
47+
.fetch_all::<MyRow>()
4848
.await?;
4949

5050
println!("{rows:#?}");
@@ -61,7 +61,7 @@ type MultiLineString = Vec<LineString>;
6161

6262
#[derive(Clone, Debug, PartialEq)]
6363
#[derive(clickhouse::Row, serde::Serialize, serde::Deserialize)]
64-
pub struct Row {
64+
pub struct MyRow {
6565
arr: Vec<String>,
6666
arr2: Vec<Vec<String>>,
6767
map: Vec<(String, u32)>,
@@ -81,10 +81,10 @@ pub struct Row {
8181
multi_line_string: MultiLineString,
8282
}
8383

84-
impl Row {
84+
impl MyRow {
8585
pub fn new() -> Self {
8686
let mut rng = rand::rng();
87-
Row {
87+
MyRow {
8888
arr: vec![random_str()],
8989
arr2: vec![vec![random_str()]],
9090
map: vec![(random_str(), 42)],
@@ -104,7 +104,7 @@ impl Row {
104104
}
105105
}
106106

107-
impl Default for Row {
107+
impl Default for MyRow {
108108
fn default() -> Self {
109109
Self::new()
110110
}

examples/data_types_derive_simple.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ async fn main() -> Result<()> {
8080
.execute()
8181
.await?;
8282

83-
let mut insert = client.insert::<Row>(table_name).await?;
84-
insert.write(&Row::new()).await?;
83+
let mut insert = client.insert::<MyRow>(table_name).await?;
84+
insert.write(&MyRow::new()).await?;
8585
insert.end().await?;
8686

8787
let rows = client
8888
.query("SELECT ?fields FROM ?")
8989
.bind(Identifier(table_name))
90-
.fetch_all::<Row>()
90+
.fetch_all::<MyRow>()
9191
.await?;
9292

9393
println!("{rows:#?}");
@@ -96,7 +96,7 @@ async fn main() -> Result<()> {
9696

9797
#[derive(Clone, Debug, PartialEq)]
9898
#[derive(clickhouse::Row, serde::Serialize, serde::Deserialize)]
99-
pub struct Row {
99+
pub struct MyRow {
100100
pub int8: i8,
101101
pub int16: i16,
102102
pub int32: i32,
@@ -191,10 +191,10 @@ pub enum Enum16 {
191191
Qux = 255,
192192
}
193193

194-
impl Row {
194+
impl MyRow {
195195
pub fn new() -> Self {
196196
let mut rng = rand::rng();
197-
Row {
197+
MyRow {
198198
int8: rng.random(),
199199
int16: rng.random(),
200200
int32: rng.random(),
@@ -259,7 +259,7 @@ impl Row {
259259
}
260260
}
261261

262-
impl Default for Row {
262+
impl Default for MyRow {
263263
fn default() -> Self {
264264
Self::new()
265265
}

examples/data_types_new_json.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use clickhouse_derive::Row;
21
use serde::{Deserialize, Serialize};
32

43
use clickhouse::sql::Identifier;
5-
use clickhouse::{Client, error::Result};
4+
use clickhouse::{Client, Row, error::Result};
65

76
// Requires ClickHouse 24.10+, as the `input_format_binary_read_json_as_string` and `output_format_binary_write_json_as_string` settings were added in that version.
87
// Inserting and selecting a row with a JSON column as a string.
@@ -35,7 +34,7 @@ async fn main() -> Result<()> {
3534
.execute()
3635
.await?;
3736

38-
let row = Row {
37+
let row = MyRow {
3938
id: 1,
4039
data: r#"
4140
{
@@ -49,14 +48,14 @@ async fn main() -> Result<()> {
4948
.to_string(),
5049
};
5150

52-
let mut insert = client.insert::<Row>(table_name).await?;
51+
let mut insert = client.insert::<MyRow>(table_name).await?;
5352
insert.write(&row).await?;
5453
insert.end().await?;
5554

5655
let db_row = client
5756
.query("SELECT ?fields FROM ? LIMIT 1")
5857
.bind(Identifier(table_name))
59-
.fetch_one::<Row>()
58+
.fetch_one::<MyRow>()
6059
.await?;
6160

6261
println!("{db_row:#?}");
@@ -69,7 +68,7 @@ async fn main() -> Result<()> {
6968
}
7069

7170
#[derive(Debug, Row, Serialize, Deserialize)]
72-
pub struct Row {
71+
pub struct MyRow {
7372
id: u64,
7473
data: String,
7574
}

examples/data_types_variant.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use clickhouse_derive::Row;
21
use serde::{Deserialize, Serialize};
32

43
use clickhouse::sql::Identifier;
5-
use clickhouse::{Client, error::Result};
4+
use clickhouse::{Client, Row, error::Result};
65

76
// See also: https://clickhouse.com/docs/en/sql-reference/data-types/variant
87

examples/session_id.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use clickhouse_derive::Row;
21
use serde::{Deserialize, Serialize};
32
use uuid::Uuid;
43

54
use clickhouse::sql::Identifier;
6-
use clickhouse::{Client, error::Result};
5+
use clickhouse::{Client, Row, error::Result};
76

87
/// Besides [`Client::with_option`], which will be applied for all requests,
98
/// `session_id` (and other settings) can be set separately for a particular `query`, `insert`,

derive/Cargo.toml renamed to macros/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "clickhouse-derive"
3-
description = "A macro for deriving clickhouse::Row"
2+
name = "clickhouse-macros"
3+
description = "Renamed from clickhouse-derive. A macro for deriving clickhouse::Row"
44
version = "0.3.0"
55

66
authors.workspace = true

0 commit comments

Comments
 (0)