(self)
| 1545 | await conn.close() |
| 1546 | |
| 1547 | async def test_custom_codec_composite_tuple(self): |
| 1548 | await self.con.execute(''' |
| 1549 | CREATE TYPE mycomplex AS (r float, i float); |
| 1550 | ''') |
| 1551 | |
| 1552 | try: |
| 1553 | await self.con.set_type_codec( |
| 1554 | 'mycomplex', |
| 1555 | encoder=lambda x: (x.real, x.imag), |
| 1556 | decoder=lambda t: complex(t[0], t[1]), |
| 1557 | format='tuple', |
| 1558 | ) |
| 1559 | |
| 1560 | num = complex('1+2j') |
| 1561 | |
| 1562 | res = await self.con.fetchval( |
| 1563 | 'SELECT $1::mycomplex', |
| 1564 | num, |
| 1565 | ) |
| 1566 | |
| 1567 | self.assertEqual(num, res) |
| 1568 | |
| 1569 | finally: |
| 1570 | await self.con.execute(''' |
| 1571 | DROP TYPE mycomplex; |
| 1572 | ''') |
| 1573 | |
| 1574 | async def test_custom_codec_composite_non_tuple(self): |
| 1575 | await self.con.execute(''' |
nothing calls this directly
no test coverage detected