(
&'a self,
v: &'a CreateTableStatement<T>,
)
| 193 | } |
| 194 | |
| 195 | pub(crate) fn doc_create_table<'a, T: AstInfo>( |
| 196 | &'a self, |
| 197 | v: &'a CreateTableStatement<T>, |
| 198 | ) -> RcDoc<'a> { |
| 199 | let mut docs = Vec::new(); |
| 200 | |
| 201 | // CREATE [TEMPORARY] TABLE [IF NOT EXISTS] name |
| 202 | let mut title = "CREATE ".to_string(); |
| 203 | if v.temporary { |
| 204 | title.push_str("TEMPORARY "); |
| 205 | } |
| 206 | title.push_str("TABLE"); |
| 207 | if v.if_not_exists { |
| 208 | title.push_str(" IF NOT EXISTS"); |
| 209 | } |
| 210 | |
| 211 | // Table name and columns/constraints |
| 212 | let mut col_items = Vec::new(); |
| 213 | col_items.extend(v.columns.iter().map(|c| self.doc_display_pass(c))); |
| 214 | col_items.extend(v.constraints.iter().map(|c| self.doc_display_pass(c))); |
| 215 | |
| 216 | let table_def = nest( |
| 217 | self.doc_display_pass(&v.name), |
| 218 | bracket("(", comma_separated(col_items), ")"), |
| 219 | ); |
| 220 | docs.push(nest_title(title, table_def)); |
| 221 | |
| 222 | // WITH options |
| 223 | if !v.with_options.is_empty() { |
| 224 | docs.push(bracket( |
| 225 | "WITH (", |
| 226 | comma_separate(|wo| self.doc_display_pass(wo), &v.with_options), |
| 227 | ")", |
| 228 | )); |
| 229 | } |
| 230 | |
| 231 | RcDoc::intersperse(docs, Doc::line()).group() |
| 232 | } |
| 233 | |
| 234 | pub(crate) fn doc_create_table_from_source<'a, T: AstInfo>( |
| 235 | &'a self, |
no test coverage detected