MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / fmt

Method fmt

src/sql-parser/src/ast/metadata.rs:111–136  ·  view source on GitHub ↗
(&self, f: &mut AstFormatter<W>)

Source from the content-addressed store, hash-verified

109
110impl AstDisplay for RawItemName {
111 fn fmt<W: fmt::Write>(&self, f: &mut AstFormatter<W>) {
112 match self {
113 RawItemName::Name(o) => f.write_node(o),
114 RawItemName::Id(id, o, v) => {
115 // `id` is parsed from an identifier token (`[<id> AS …]`), so a
116 // crafted id with spaces/keywords must be quoted to reparse as a
117 // single identifier. A normal global id like `u1` is printed
118 // bare in every mode — including the stable mode `pg_get_viewdef`
119 // renders in, which would otherwise force-quote it.
120 f.write_str("[");
121 let id = Ident::new_unchecked(id.clone());
122 if id.can_be_printed_bare() {
123 f.write_str(id.as_str());
124 } else {
125 f.write_node(&id);
126 }
127 f.write_str(" AS ");
128 f.write_node(o);
129 if let Some(v) = v {
130 f.write_str(" VERSION ");
131 f.write_node(v);
132 }
133 f.write_str("]");
134 }
135 }
136 }
137}
138impl_display!(RawItemName);
139

Callers

nothing calls this directly

Calls 12

write_nodeMethod · 0.80
can_be_printed_bareMethod · 0.80
as_keywordMethod · 0.80
to_ast_string_stableMethod · 0.80
comma_separatedFunction · 0.70
write_strMethod · 0.45
cloneMethod · 0.45
as_strMethod · 0.45
mapMethod · 0.45
firstMethod · 0.45
nameMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected