diff --git a/CHANGELOG.md b/CHANGELOG.md index 8920502de..c1499d8f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 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/Cargo.toml b/Cargo.toml index ee070f198..de8ae1923 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "quaint" -version = "0.1.12" +version = "0.1.13" authors = [ "Julius de Bruijn ", "Katharina Fey ", diff --git a/src/visitor.rs b/src/visitor.rs index 26850555b..4b7f63ef8 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() {