Skip to content

Commit

Permalink
Merge pull request #23 from hasura:fix-foreach
Browse files Browse the repository at this point in the history
Fix-foreach
  • Loading branch information
BenoitRanque authored Aug 14, 2024
2 parents dbe5b77 + 269f593 commit 7ef634c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.2.11]

- Bugfix: add missing group by clause for `foreach` queries. This should fix remote relationships.

## [0.2.10]

- Correct CLI implementation of Init command (used to behave the same as update)
Expand Down
24 changes: 9 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ members = [
]
resolver = "2"

package.version = "0.2.10"
package.version = "0.2.11"
package.edition = "2021"
2 changes: 1 addition & 1 deletion crates/ndc-clickhouse/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ schemars = "0.8.16"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
sqlformat = "0.2.3"
strum = { version = "0.26.2", features = ["derive"] }
strum = { version = "0.26.3", features = ["derive"] }
tokio = "1.36.0"
tracing = "0.1.40"
10 changes: 10 additions & 0 deletions crates/ndc-clickhouse/src/sql/query_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,20 @@ impl<'r, 'c> QueryBuilder<'r, 'c> {
vec![]
};

let group_by = if self.request.variables.is_some() {
vec![Expr::CompoundIdentifier(vec![
Ident::new_quoted("_vars"),
Ident::new_quoted("_varset_id"),
])]
} else {
vec![]
};

Ok(Query::new()
.with(with)
.select(select)
.from(from)
.group_by(group_by)
.order_by(order_by)
.into_statement()
.format("TabSeparatedRaw"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ FROM
GROUP BY
"_row"."_varset_id"
) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id"
GROUP BY
"_vars"."_varset_id"
ORDER BY
"_vars"."_varset_id" ASC FORMAT TabSeparatedRaw;
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ FROM
GROUP BY
"_row"."_varset_id"
) AS "_rowset" ON "_vars"."_varset_id" = "_rowset"."_varset_id"
GROUP BY
"_vars"."_varset_id"
ORDER BY
"_vars"."_varset_id" ASC FORMAT TabSeparatedRaw;

0 comments on commit 7ef634c

Please sign in to comment.