(stmt, executemany, id_param_name, expect_success)
| 643 | t = self.tables.t |
| 644 | |
| 645 | def go(stmt, executemany, id_param_name, expect_success): |
| 646 | stmt = stmt.returning(t.c.id) |
| 647 | |
| 648 | if executemany: |
| 649 | if not expect_success: |
| 650 | # for RETURNING executemany(), we raise our own |
| 651 | # error as this is independent of general RETURNING |
| 652 | # support |
| 653 | with expect_raises_message( |
| 654 | exc.StatementError, |
| 655 | rf"Dialect {connection.dialect.name}\+" |
| 656 | f"{connection.dialect.driver} with " |
| 657 | f"current server capabilities does not support " |
| 658 | f".*RETURNING when executemany is used", |
| 659 | ): |
| 660 | connection.execute( |
| 661 | stmt, |
| 662 | [ |
| 663 | {id_param_name: 1, "data": "d1"}, |
| 664 | {id_param_name: 2, "data": "d2"}, |
| 665 | {id_param_name: 3, "data": "d3"}, |
| 666 | ], |
| 667 | ) |
| 668 | else: |
| 669 | result = connection.execute( |
| 670 | stmt, |
| 671 | [ |
| 672 | {id_param_name: 1, "data": "d1"}, |
| 673 | {id_param_name: 2, "data": "d2"}, |
| 674 | {id_param_name: 3, "data": "d3"}, |
| 675 | ], |
| 676 | ) |
| 677 | eq_(result.all(), [(1,), (2,), (3,)]) |
| 678 | else: |
| 679 | if not expect_success: |
| 680 | # for RETURNING execute(), we pass all the way to the DB |
| 681 | # and let it fail |
| 682 | with expect_raises(exc.DBAPIError): |
| 683 | connection.execute( |
| 684 | stmt, {id_param_name: 1, "data": "d1"} |
| 685 | ) |
| 686 | else: |
| 687 | result = connection.execute( |
| 688 | stmt, {id_param_name: 1, "data": "d1"} |
| 689 | ) |
| 690 | eq_(result.all(), [(1,)]) |
| 691 | |
| 692 | return go |
| 693 |
nothing calls this directly
no test coverage detected