diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dc8ad5b6..30a0b29df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v0.2.0-alpha.9 + +- Correct position for GROUP BY if having ORDER BY in the same clause + +## v0.2.0-alpha.8 + - AVG and SUM implementations ## v0.2.0-alpha.7 @@ -37,6 +43,10 @@ Breaking changes ahead - Unique/null constr error should be multi-column (https://github.com/prisma/quaint/pull/62) - Add optional serde support (https://github.com/prisma/quaint/pull/63) +## v0.1.13 + +- Correct position for GROUP BY if having ORDER BY in the same clause + ## v0.1.12 - Add a ParameterizedValue::Enum in order to support writing to native enum columns in Postgres diff --git a/src/visitor.rs b/src/visitor.rs index 439dc9b95..0d97b131a 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -156,10 +156,6 @@ pub trait Visitor<'a> { self.write(" WHERE ")?; self.visit_conditions(conditions)?; } - if !select.ordering.is_empty() { - self.write(" ORDER BY ")?; - self.visit_ordering(select.ordering)?; - } if !select.grouping.is_empty() { self.write(" GROUP BY ")?; self.visit_grouping(select.grouping)?; @@ -168,6 +164,10 @@ pub trait Visitor<'a> { self.write(" HAVING ")?; self.visit_conditions(conditions)?; } + if !select.ordering.is_empty() { + self.write(" ORDER BY ")?; + self.visit_ordering(select.ordering)?; + } self.visit_limit_and_offset(select.limit, select.offset)?; } else if select.columns.is_empty() {