(self)
| 1591 | await conn.close() |
| 1592 | |
| 1593 | async def test_custom_codec_composite_tuple(self): |
| 1594 | await self.con.execute(''' |
| 1595 | CREATE TYPE mycomplex AS (r float, i float); |
| 1596 | ''') |
| 1597 | |
| 1598 | try: |
| 1599 | await self.con.set_type_codec( |
| 1600 | 'mycomplex', |
| 1601 | encoder=lambda x: (x.real, x.imag), |
| 1602 | decoder=lambda t: complex(t[0], t[1]), |
| 1603 | format='tuple', |
| 1604 | ) |
| 1605 | |
| 1606 | num = complex('1+2j') |
| 1607 | |
| 1608 | res = await self.con.fetchval( |
| 1609 | 'SELECT $1::mycomplex', |
| 1610 | num, |
| 1611 | ) |
| 1612 | |
| 1613 | self.assertEqual(num, res) |
| 1614 | |
| 1615 | finally: |
| 1616 | await self.con.execute(''' |
| 1617 | DROP TYPE mycomplex; |
| 1618 | ''') |
| 1619 | |
| 1620 | async def test_custom_codec_composite_non_tuple(self): |
| 1621 | await self.con.execute(''' |
nothing calls this directly
no test coverage detected