Ensure comments are output with DEFINE statements (#2500)

This commit is contained in:
Tobie Morgan Hitchcock 2023-08-23 17:04:42 +01:00 committed by GitHub
parent b1275ed565
commit 495f69d618
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 3 deletions

View file

@ -66,7 +66,11 @@ impl Display for DefineEventStatement {
f,
"DEFINE EVENT {} ON {} WHEN {} THEN {}",
self.name, self.what, self.when, self.then
)
)?;
if let Some(ref v) = self.comment {
write!(f, " COMMENT {v}")?
}
Ok(())
}
}

View file

@ -84,6 +84,9 @@ impl Display for DefineFieldStatement {
if let Some(ref v) = self.assert {
write!(f, " ASSERT {v}")?
}
if let Some(ref v) = self.comment {
write!(f, " COMMENT {v}")?
}
if !self.permissions.is_full() {
write!(f, " {}", self.permissions)?;
}

View file

@ -90,6 +90,9 @@ impl Display for DefineIndexStatement {
if Index::Idx != self.index {
write!(f, " {}", self.index)?;
}
if let Some(ref v) = self.comment {
write!(f, " COMMENT {v}")?
}
Ok(())
}
}

View file

@ -55,7 +55,11 @@ impl DefineParamStatement {
impl Display for DefineParamStatement {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "DEFINE PARAM ${} VALUE {}", self.name, self.value)
write!(f, "DEFINE PARAM ${} VALUE {}", self.name, self.value)?;
if let Some(ref v) = self.comment {
write!(f, " COMMENT {v}")?
}
Ok(())
}
}

View file

@ -70,6 +70,9 @@ impl Display for DefineScopeStatement {
if let Some(ref v) = self.signin {
write!(f, " SIGNIN {v}")?
}
if let Some(ref v) = self.comment {
write!(f, " COMMENT {v}")?
}
Ok(())
}
}

View file

@ -113,6 +113,9 @@ impl Display for DefineTableStatement {
} else {
" SCHEMALESS"
})?;
if let Some(ref v) = self.comment {
write!(f, " COMMENT {v}")?
}
if let Some(ref v) = self.view {
write!(f, " {v}")?
}

View file

@ -128,7 +128,11 @@ impl Display for DefineUserStatement {
Fmt::comma_separated(
&self.roles.iter().map(|r| r.to_string().to_uppercase()).collect::<Vec<String>>()
)
)
)?;
if let Some(ref v) = self.comment {
write!(f, " COMMENT {v}")?
}
Ok(())
}
}