Skip to content

Commit d41ac2b

Browse files
committed
doc: Add a note about JSON object in results.
1 parent 38b722c commit d41ac2b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/query.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ impl Query {
9393
}
9494

9595
/// Executes the query, returning a [`watch::RowJsonCursor`] to obtain results.
96+
///
97+
/// Beware that with `JSONEachRow` format, Clickhouse always returns
98+
/// a JSON object in the `{ "column1": value1, "column2": value2 }` format and not as `[value1, value2]`.
9699
#[cfg(feature = "watch")]
97100
pub fn fetch_json<T>(mut self) -> Result<watch::RowJsonCursor<T>> {
98101
self.sql.append(" FORMAT JSONEachRowWithProgress");
@@ -104,6 +107,9 @@ impl Query {
104107
/// Executes the query and returns just a single row.
105108
///
106109
/// Note that `T` must be owned.
110+
///
111+
/// Beware that with `JSONEachRow` format, Clickhouse always returns
112+
/// a JSON object in the `{ "column1": value1, "column2": value2 }` format and not as `[value1, value2]`.
107113
#[cfg(feature = "watch")]
108114
pub async fn fetch_json_one<T>(self) -> Result<T>
109115
where
@@ -119,6 +125,9 @@ impl Query {
119125
/// Executes the query and returns at most one row.
120126
///
121127
/// Note that `T` must be owned.
128+
///
129+
/// Beware that with `JSONEachRow` format, Clickhouse always returns
130+
/// a JSON object in the `{ "column1": value1, "column2": value2 }` format and not as `[value1, value2]`.
122131
#[cfg(feature = "watch")]
123132
pub async fn fetch_json_optional<T>(self) -> Result<Option<T>>
124133
where
@@ -131,6 +140,9 @@ impl Query {
131140
/// collected into a [`Vec`].
132141
///
133142
/// Note that `T` must be owned.
143+
///
144+
/// Beware that with `JSONEachRow` format, Clickhouse always returns
145+
/// a JSON object in the `{ "column1": value1, "column2": value2 }` format and not as `[value1, value2]`.
134146
#[cfg(feature = "watch")]
135147
pub async fn fetch_json_all<T>(self) -> Result<Vec<T>>
136148
where

0 commit comments

Comments
 (0)