(&'a self, v: &'a Query<T>)
| 947 | } |
| 948 | |
| 949 | fn doc_query<'a, T: AstInfo>(&'a self, v: &'a Query<T>) -> RcDoc<'a> { |
| 950 | let mut docs = vec![]; |
| 951 | if !v.ctes.is_empty() { |
| 952 | match &v.ctes { |
| 953 | CteBlock::Simple(ctes) => { |
| 954 | docs.push(title_comma_separate("WITH", |cte| self.doc_cte(cte), ctes)) |
| 955 | } |
| 956 | CteBlock::MutuallyRecursive(mutrec) => { |
| 957 | let mut doc = RcDoc::text("WITH MUTUALLY RECURSIVE"); |
| 958 | if !mutrec.options.is_empty() { |
| 959 | doc = nest( |
| 960 | doc, |
| 961 | bracket( |
| 962 | "(", |
| 963 | comma_separate(|o| self.doc_display_pass(o), &mutrec.options), |
| 964 | ")", |
| 965 | ), |
| 966 | ); |
| 967 | } |
| 968 | docs.push(nest( |
| 969 | doc, |
| 970 | comma_separate(|c| self.doc_mutually_recursive(c), &mutrec.ctes), |
| 971 | )); |
| 972 | } |
| 973 | } |
| 974 | } |
| 975 | docs.push(self.doc_set_expr(&v.body)); |
| 976 | if !v.order_by.is_empty() { |
| 977 | docs.push(self.doc_order_by(&v.order_by)); |
| 978 | } |
| 979 | |
| 980 | let offset = if let Some(offset) = &v.offset { |
| 981 | vec![RcDoc::concat([nest_title("OFFSET", self.doc_expr(offset))])] |
| 982 | } else { |
| 983 | vec![] |
| 984 | }; |
| 985 | |
| 986 | if let Some(limit) = &v.limit { |
| 987 | if limit.with_ties { |
| 988 | docs.extend(offset); |
| 989 | docs.push(RcDoc::concat([ |
| 990 | RcDoc::text("FETCH FIRST "), |
| 991 | self.doc_expr(&limit.quantity), |
| 992 | RcDoc::text(" ROWS WITH TIES"), |
| 993 | ])); |
| 994 | } else { |
| 995 | docs.push(nest_title("LIMIT", self.doc_expr(&limit.quantity))); |
| 996 | docs.extend(offset); |
| 997 | } |
| 998 | } else { |
| 999 | docs.extend(offset); |
| 1000 | } |
| 1001 | |
| 1002 | RcDoc::intersperse(docs, Doc::line()).group() |
| 1003 | } |
| 1004 | |
| 1005 | fn doc_cte<'a, T: AstInfo>(&'a self, v: &'a Cte<T>) -> RcDoc<'a> { |
| 1006 | RcDoc::concat([ |
no test coverage detected