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

Method doc_create_connection

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

Source from the content-addressed store, hash-verified

309 }
310
311 pub(crate) fn doc_create_connection<'a, T: AstInfo>(
312 &'a self,
313 v: &'a CreateConnectionStatement<T>,
314 ) -> RcDoc<'a> {
315 let mut docs = Vec::new();
316
317 let mut title = "CREATE CONNECTION".to_string();
318 if v.if_not_exists {
319 title.push_str(" IF NOT EXISTS");
320 }
321 docs.push(nest_title(title, self.doc_display_pass(&v.name)));
322
323 let connection_with_values = nest(
324 RcDoc::concat([
325 RcDoc::text("TO "),
326 self.doc_display_pass(&v.connection_type),
327 ]),
328 bracket(
329 "(",
330 comma_separate(|val| self.doc_display_pass(val), &v.values),
331 ")",
332 ),
333 );
334 docs.push(connection_with_values);
335
336 if !v.with_options.is_empty() {
337 docs.push(bracket(
338 "WITH (",
339 comma_separate(|wo| self.doc_display_pass(wo), &v.with_options),
340 ")",
341 ));
342 }
343
344 RcDoc::intersperse(docs, Doc::line()).group()
345 }
346
347 pub(crate) fn doc_create_sink<'a, T: AstInfo>(
348 &'a self,

Callers 1

to_docMethod · 0.80

Calls 10

nest_titleFunction · 0.85
nestFunction · 0.85
concatFunction · 0.85
bracketFunction · 0.85
comma_separateFunction · 0.85
doc_display_passMethod · 0.80
groupMethod · 0.80
to_stringMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected