Skip to content

Commit

Permalink
doc: Add a note about JSON object in results.
Browse files Browse the repository at this point in the history
  • Loading branch information
pravic committed Nov 28, 2024
1 parent 38b722c commit d41ac2b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ impl Query {
}

/// Executes the query, returning a [`watch::RowJsonCursor`] to obtain results.
///
/// Beware that with `JSONEachRow` format, Clickhouse always returns
/// a JSON object in the `{ "column1": value1, "column2": value2 }` format and not as `[value1, value2]`.
#[cfg(feature = "watch")]
pub fn fetch_json<T>(mut self) -> Result<watch::RowJsonCursor<T>> {
self.sql.append(" FORMAT JSONEachRowWithProgress");
Expand All @@ -104,6 +107,9 @@ impl Query {
/// Executes the query and returns just a single row.
///
/// Note that `T` must be owned.
///
/// Beware that with `JSONEachRow` format, Clickhouse always returns
/// a JSON object in the `{ "column1": value1, "column2": value2 }` format and not as `[value1, value2]`.
#[cfg(feature = "watch")]
pub async fn fetch_json_one<T>(self) -> Result<T>
where
Expand All @@ -119,6 +125,9 @@ impl Query {
/// Executes the query and returns at most one row.
///
/// Note that `T` must be owned.
///
/// Beware that with `JSONEachRow` format, Clickhouse always returns
/// a JSON object in the `{ "column1": value1, "column2": value2 }` format and not as `[value1, value2]`.
#[cfg(feature = "watch")]
pub async fn fetch_json_optional<T>(self) -> Result<Option<T>>
where
Expand All @@ -131,6 +140,9 @@ impl Query {
/// collected into a [`Vec`].
///
/// Note that `T` must be owned.
///
/// Beware that with `JSONEachRow` format, Clickhouse always returns
/// a JSON object in the `{ "column1": value1, "column2": value2 }` format and not as `[value1, value2]`.
#[cfg(feature = "watch")]
pub async fn fetch_json_all<T>(self) -> Result<Vec<T>>
where
Expand Down

0 comments on commit d41ac2b

Please sign in to comment.