diff --git a/lib/src/sql/array.rs b/lib/src/sql/array.rs index 02b272eb..3b9acbf3 100644 --- a/lib/src/sql/array.rs +++ b/lib/src/sql/array.rs @@ -153,9 +153,11 @@ impl Display for Array { fn fmt(&self, f: &mut Formatter) -> fmt::Result { let mut f = Pretty::from(f); f.write_char('[')?; - let indent = pretty_indent(); - write!(f, "{}", Fmt::pretty_comma_separated(self.as_slice()))?; - drop(indent); + if !self.is_empty() { + let indent = pretty_indent(); + write!(f, "{}", Fmt::pretty_comma_separated(self.as_slice()))?; + drop(indent); + } f.write_char(']') } } diff --git a/lib/src/sql/object.rs b/lib/src/sql/object.rs index fdfac3cc..8f65a3c3 100644 --- a/lib/src/sql/object.rs +++ b/lib/src/sql/object.rs @@ -144,20 +144,22 @@ impl Display for Object { } else { f.write_str("{ ")?; } - let indent = pretty_indent(); - write!( - f, - "{}", - Fmt::pretty_comma_separated( - self.0.iter().map(|args| Fmt::new(args, |(k, v), f| write!( - f, - "{}: {}", - escape_key(k), - v - ))), - ) - )?; - drop(indent); + if !self.is_empty() { + let indent = pretty_indent(); + write!( + f, + "{}", + Fmt::pretty_comma_separated( + self.0.iter().map(|args| Fmt::new(args, |(k, v), f| write!( + f, + "{}: {}", + escape_key(k), + v + ))), + ) + )?; + drop(indent); + } if is_pretty() { f.write_char('}') } else {