| 34 | self.fail('UndefinedTableError not raised') |
| 35 | |
| 36 | async def test_exceptions_str(self): |
| 37 | try: |
| 38 | await self.con.execute(''' |
| 39 | CREATE FUNCTION foo() RETURNS bool AS $$ $$ LANGUAGE SQL; |
| 40 | ''') |
| 41 | except asyncpg.InvalidFunctionDefinitionError as e: |
| 42 | if self.server_version < (17, 0): |
| 43 | detail = ( |
| 44 | "Function's final statement must be SELECT or " |
| 45 | "INSERT/UPDATE/DELETE RETURNING." |
| 46 | ) |
| 47 | else: |
| 48 | detail = ( |
| 49 | "Function's final statement must be SELECT or " |
| 50 | "INSERT/UPDATE/DELETE/MERGE RETURNING." |
| 51 | ) |
| 52 | |
| 53 | self.assertEqual(e.detail, detail) |
| 54 | self.assertIn('DETAIL: Function', str(e)) |
| 55 | else: |
| 56 | self.fail('InvalidFunctionDefinitionError not raised') |