Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ast): fix incorrect display for ast (part 1) #15069

Merged
merged 13 commits into from
Mar 23, 2024
Empty file modified scripts/ci/ci-run-sqlsmith-tests.sh
100644 → 100755
Empty file.
6 changes: 0 additions & 6 deletions src/meta/app/src/principal/file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ pub struct FileFormatOptionsAst {
pub options: BTreeMap<String, String>,
}

impl Display for FileFormatOptionsAst {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.options)
}
}

impl FileFormatOptionsAst {
pub fn new(options: BTreeMap<String, String>) -> Self {
FileFormatOptionsAst { options }
Expand Down
2 changes: 1 addition & 1 deletion src/meta/app/src/principal/principal_identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl fmt::Display for PrincipalIdentity {
fn fmt(&self, f: &mut fmt::Formatter) -> std::result::Result<(), fmt::Error> {
match self {
PrincipalIdentity::User(u) => write!(f, " USER {u}"),
PrincipalIdentity::Role(r) => write!(f, " ROLE {r}"),
PrincipalIdentity::Role(r) => write!(f, " ROLE '{r}'"),
}
}
}
30 changes: 29 additions & 1 deletion src/query/ast/src/ast/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub(crate) fn write_comma_separated_list(
}

/// Write input items into `'a', 'b', 'c'`
pub(crate) fn write_comma_separated_quoted_list(
pub(crate) fn write_comma_separated_string_list(
f: &mut Formatter<'_>,
items: impl IntoIterator<Item = impl Display>,
) -> std::fmt::Result {
Expand All @@ -238,6 +238,34 @@ pub(crate) fn write_comma_separated_map(
if i > 0 {
write!(f, ", ")?;
}
write!(f, "{k} = {v}")?;
}
Ok(())
}

/// Write input map items into `field_a='x', field_b='y'`
pub(crate) fn write_comma_separated_string_map(
f: &mut Formatter<'_>,
items: impl IntoIterator<Item = (impl Display, impl Display)>,
) -> std::fmt::Result {
for (i, (k, v)) in items.into_iter().enumerate() {
if i > 0 {
write!(f, ", ")?;
}
write!(f, "{k} = '{v}'")?;
}
Ok(())
}

/// Write input map items into `field_a='x' field_b='y'`
pub(crate) fn write_space_separated_string_map(
f: &mut Formatter<'_>,
items: impl IntoIterator<Item = (impl Display, impl Display)>,
) -> std::fmt::Result {
for (i, (k, v)) in items.into_iter().enumerate() {
if i > 0 {
write!(f, " ")?;
}
write!(f, "{k} = '{v}'")?;
}
Ok(())
Expand Down
Loading
Loading