(
&'a self,
v: &'a SubscribeStatement<T>,
)
| 632 | } |
| 633 | |
| 634 | pub(crate) fn doc_subscribe<'a, T: AstInfo>( |
| 635 | &'a self, |
| 636 | v: &'a SubscribeStatement<T>, |
| 637 | ) -> RcDoc<'a> { |
| 638 | let doc = match &v.relation { |
| 639 | SubscribeRelation::Name(name) => { |
| 640 | let title = if v.relation.needs_explicit_to(matches!( |
| 641 | self.config.format_mode, |
| 642 | FormatMode::Simple | FormatMode::SimpleRedacted |
| 643 | )) { |
| 644 | "SUBSCRIBE TO" |
| 645 | } else { |
| 646 | "SUBSCRIBE" |
| 647 | }; |
| 648 | nest_title(title, self.doc_display_pass(name)) |
| 649 | } |
| 650 | SubscribeRelation::Query(query) => bracket("SUBSCRIBE (", self.doc_query(query), ")"), |
| 651 | }; |
| 652 | let mut docs = vec![doc]; |
| 653 | if !v.options.is_empty() { |
| 654 | docs.push(bracket( |
| 655 | "WITH (", |
| 656 | comma_separate(|o| self.doc_display_pass(o), &v.options), |
| 657 | ")", |
| 658 | )); |
| 659 | } |
| 660 | if let Some(as_of) = &v.as_of { |
| 661 | docs.push(self.doc_as_of(as_of)); |
| 662 | } |
| 663 | if let Some(up_to) = &v.up_to { |
| 664 | docs.push(nest_title("UP TO", self.doc_expr(up_to))); |
| 665 | } |
| 666 | match &v.output { |
| 667 | SubscribeOutput::Diffs => {} |
| 668 | SubscribeOutput::WithinTimestampOrderBy { order_by } => { |
| 669 | docs.push(nest_title( |
| 670 | "WITHIN TIMESTAMP ORDER BY ", |
| 671 | comma_separate(|o| self.doc_order_by_expr(o), order_by), |
| 672 | )); |
| 673 | } |
| 674 | SubscribeOutput::EnvelopeUpsert { key_columns } => { |
| 675 | docs.push(bracket( |
| 676 | "ENVELOPE UPSERT (KEY (", |
| 677 | comma_separate(|kc| self.doc_display_pass(kc), key_columns), |
| 678 | "))", |
| 679 | )); |
| 680 | } |
| 681 | SubscribeOutput::EnvelopeDebezium { key_columns } => { |
| 682 | docs.push(bracket( |
| 683 | "ENVELOPE DEBEZIUM (KEY (", |
| 684 | comma_separate(|kc| self.doc_display_pass(kc), key_columns), |
| 685 | "))", |
| 686 | )); |
| 687 | } |
| 688 | } |
| 689 | RcDoc::intersperse(docs, Doc::line()).group() |
| 690 | } |
| 691 |
no test coverage detected