Fix Display
implementation for empty Groups
(#1788)
This commit is contained in:
parent
1d27273d7e
commit
e075be16b8
1 changed files with 13 additions and 1 deletions
|
@ -32,8 +32,12 @@ impl IntoIterator for Groups {
|
||||||
|
|
||||||
impl Display for Groups {
|
impl Display for Groups {
|
||||||
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
||||||
|
if self.0.is_empty() {
|
||||||
|
write!(f, "GROUP ALL")
|
||||||
|
} else {
|
||||||
write!(f, "GROUP BY {}", Fmt::comma_separated(&self.0))
|
write!(f, "GROUP BY {}", Fmt::comma_separated(&self.0))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
||||||
|
@ -114,4 +118,12 @@ mod tests {
|
||||||
);
|
);
|
||||||
assert_eq!("GROUP BY field, other.field", format!("{}", out));
|
assert_eq!("GROUP BY field, other.field", format!("{}", out));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn group_statement_all() {
|
||||||
|
let sql = "GROUP ALL";
|
||||||
|
let out = group(sql).unwrap().1;
|
||||||
|
assert_eq!(out, Groups(Vec::new()));
|
||||||
|
assert_eq!(sql, out.to_string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue