Fix type not included in LET statement display (#4615)

This commit is contained in:
Julian 2024-08-27 16:35:21 +02:00 committed by GitHub
parent 9ca3a4d087
commit 6af8ea9165
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;");
}
}