From 6af8ea916515986887f747b707bd36b0d1755c7d Mon Sep 17 00:00:00 2001 From: Julian Date: Tue, 27 Aug 2024 16:35:21 +0200 Subject: [PATCH] Fix type not included in LET statement display (#4615) --- core/src/sql/statements/set.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/core/src/sql/statements/set.rs b/core/src/sql/statements/set.rs index e6c8b83e..35ab70c1 100644 --- a/core/src/sql/statements/set.rs +++ b/core/src/sql/statements/set.rs @@ -57,6 +57,25 @@ impl SetStatement { impl fmt::Display for SetStatement { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "LET ${} = {}", self.name, self.what) + write!(f, "LET ${}", self.name)?; + if let Some(ref kind) = self.kind { + write!(f, ": {}", kind)?; + } + write!(f, " = {}", self.what)?; + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use crate::syn::parse; + + #[test] + fn check_type() { + let query = parse("LET $param = 5").unwrap(); + assert_eq!(format!("{}", query), "LET $param = 5;"); + + let query = parse("LET $param: number = 5").unwrap(); + assert_eq!(format!("{}", query), "LET $param: number = 5;"); } }