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

Method doc_insert

src/sql-pretty/src/doc.rs:882–909  ·  view source on GitHub ↗
(&'a self, v: &'a InsertStatement<T>)

Source from the content-addressed store, hash-verified

880 }
881
882 pub(crate) fn doc_insert<'a, T: AstInfo>(&'a self, v: &'a InsertStatement<T>) -> RcDoc<'a> {
883 let mut first = vec![RcDoc::text(format!(
884 "INSERT INTO {}",
885 v.table_name.to_ast_string_simple()
886 ))];
887 if !v.columns.is_empty() {
888 first.push(bracket(
889 "(",
890 comma_separate(|c| self.doc_display_pass(c), &v.columns),
891 ")",
892 ));
893 }
894 let sources = match &v.source {
895 InsertSource::Query(query) => self.doc_query(query),
896 InsertSource::DefaultValues => self.doc_display(&v.source, "insert source"),
897 };
898 let mut doc = intersperse_line_nest([intersperse_line_nest(first), sources]);
899 if !v.returning.is_empty() {
900 doc = nest(
901 doc,
902 nest_title(
903 "RETURNING",
904 comma_separate(|r| self.doc_display_pass(r), &v.returning),
905 ),
906 )
907 }
908 doc
909 }
910
911 pub(crate) fn doc_select_statement<'a, T: AstInfo>(
912 &'a self,

Callers 1

to_docMethod · 0.80

Calls 10

bracketFunction · 0.85
comma_separateFunction · 0.85
intersperse_line_nestFunction · 0.85
nestFunction · 0.85
nest_titleFunction · 0.85
doc_display_passMethod · 0.80
doc_queryMethod · 0.80
doc_displayMethod · 0.80
is_emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected