(self, node: pgast.InsertStmt)
| 433 | self.write(')') |
| 434 | |
| 435 | def visit_InsertStmt(self, node: pgast.InsertStmt) -> None: |
| 436 | if node.ctes: |
| 437 | self.write('WITH ') |
| 438 | self.gen_ctes(node.ctes) |
| 439 | |
| 440 | self.write('INSERT INTO ') |
| 441 | self.visit(node.relation) |
| 442 | if node.cols: |
| 443 | self.new_lines = 1 |
| 444 | self.indentation += 1 |
| 445 | self.write('(') |
| 446 | self.visit_list(node.cols, newlines=False) |
| 447 | self.write(')') |
| 448 | self.indentation -= 1 |
| 449 | |
| 450 | self.indentation += 1 |
| 451 | self.new_lines = 1 |
| 452 | |
| 453 | if node.select_stmt: |
| 454 | if ( |
| 455 | isinstance(node.select_stmt, pgast.SelectStmt) |
| 456 | and node.select_stmt.values |
| 457 | ): |
| 458 | self.write('VALUES ') |
| 459 | self.new_lines = 1 |
| 460 | self.indentation += 1 |
| 461 | self.visit_list(node.select_stmt.values) |
| 462 | self.indentation -= 1 |
| 463 | else: |
| 464 | self.write('(') |
| 465 | self.visit(node.select_stmt) |
| 466 | self.write(')') |
| 467 | else: |
| 468 | self.write('DEFAULT VALUES') |
| 469 | |
| 470 | if node.on_conflict: |
| 471 | self.new_lines = 1 |
| 472 | self.write('ON CONFLICT') |
| 473 | |
| 474 | if node.on_conflict.target: |
| 475 | self.visit(node.on_conflict.target) |
| 476 | |
| 477 | self.write(' DO ') |
| 478 | self.write(node.on_conflict.action[3:]) |
| 479 | |
| 480 | if node.on_conflict.update_list: |
| 481 | self.write(' SET') |
| 482 | self.new_lines = 1 |
| 483 | self.indentation += 1 |
| 484 | self.visit_list(node.on_conflict.update_list) |
| 485 | self.indentation -= 1 |
| 486 | |
| 487 | if node.on_conflict.update_where: |
| 488 | self.write(' WHERE ') |
| 489 | self.indentation += 1 |
| 490 | self.visit(node.on_conflict.update_where) |
| 491 | self.indentation -= 1 |
| 492 |
nothing calls this directly
no test coverage detected