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

Method fmt

src/sql-parser/src/ast/defs/query.rs:46–75  ·  view source on GitHub ↗
(&self, f: &mut AstFormatter<W>)

Source from the content-addressed store, hash-verified

44
45impl<T: AstInfo> AstDisplay for Query<T> {
46 fn fmt<W: fmt::Write>(&self, f: &mut AstFormatter<W>) {
47 f.write_node(&self.ctes);
48 f.write_node(&self.body);
49 if !self.order_by.is_empty() {
50 f.write_str(" ORDER BY ");
51 f.write_node(&display::comma_separated(&self.order_by));
52 }
53
54 let write_offset = |f: &mut AstFormatter<W>| {
55 if let Some(offset) = &self.offset {
56 f.write_str(" OFFSET ");
57 f.write_node(offset);
58 }
59 };
60
61 if let Some(limit) = &self.limit {
62 if limit.with_ties {
63 write_offset(f);
64 f.write_str(" FETCH FIRST ");
65 f.write_node(&limit.quantity);
66 f.write_str(" ROWS WITH TIES");
67 } else {
68 f.write_str(" LIMIT ");
69 f.write_node(&limit.quantity);
70 write_offset(f);
71 }
72 } else {
73 write_offset(f);
74 }
75 }
76}
77impl_display_t!(Query);
78

Callers

nothing calls this directly

Calls 11

write_nodeMethod · 0.80
fmt_table_callMethod · 0.80
enumerateMethod · 0.80
saturating_subMethod · 0.80
comma_separatedFunction · 0.50
is_emptyMethod · 0.45
write_strMethod · 0.45
iterMethod · 0.45
redactedMethod · 0.45
to_stringMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected