(self, ctes: list[pgast.CommonTableExpr])
| 213 | ) |
| 214 | |
| 215 | def gen_ctes(self, ctes: list[pgast.CommonTableExpr]) -> None: |
| 216 | count = len(ctes) |
| 217 | for i, cte in enumerate(ctes): |
| 218 | self.new_lines = 1 |
| 219 | if i == 0 and getattr(cte, 'recursive', None): |
| 220 | self.write('RECURSIVE ') |
| 221 | self.write(common.quote_ident(cte.name)) |
| 222 | |
| 223 | if cte.aliascolnames: |
| 224 | self.write('(') |
| 225 | for (index, col_name) in enumerate(cte.aliascolnames): |
| 226 | self.write(common.qname(col_name, column=True)) |
| 227 | if index + 1 < len(cte.aliascolnames): |
| 228 | self.write(',') |
| 229 | self.write(')') |
| 230 | |
| 231 | self.write(' AS ') |
| 232 | if cte.materialized is not None: |
| 233 | if cte.materialized: |
| 234 | self.write('MATERIALIZED ') |
| 235 | else: |
| 236 | self.write('NOT MATERIALIZED ') |
| 237 | self.indentation += 1 |
| 238 | self.new_lines = 1 |
| 239 | self.write('(') |
| 240 | self.visit(cte.query) |
| 241 | self.write(')') |
| 242 | if i != count - 1: |
| 243 | self.write(',') |
| 244 | self.indentation -= 1 |
| 245 | |
| 246 | self.new_lines = 1 |
| 247 | |
| 248 | def visit__Ref(self, node): # type: ignore |
| 249 | self.visit(node.node) |
no test coverage detected