@@ -1624,6 +1624,45 @@ async def test_enum_and_range(self):
1624
1624
DROP TYPE enum_t;
1625
1625
''' )
1626
1626
1627
+ async def test_enum_in_composite (self ):
1628
+ await self .con .execute ('''
1629
+ CREATE TYPE enum_t AS ENUM ('abc', 'def', 'ghi');
1630
+ CREATE TYPE composite_w_enum AS (a int, b enum_t);
1631
+ ''' )
1632
+
1633
+ try :
1634
+ result = await self .con .fetchval ('''
1635
+ SELECT ROW(1, 'def'::enum_t)::composite_w_enum
1636
+ ''' )
1637
+ self .assertEqual (set (result .items ()), {('a' , 1 ), ('b' , 'def' )})
1638
+
1639
+ finally :
1640
+ await self .con .execute ('''
1641
+ DROP TYPE composite_w_enum;
1642
+ DROP TYPE enum_t;
1643
+ ''' )
1644
+
1645
+ async def test_enum_function_return (self ):
1646
+ await self .con .execute ('''
1647
+ CREATE TYPE enum_t AS ENUM ('abc', 'def', 'ghi');
1648
+ CREATE FUNCTION return_enum() RETURNS enum_t
1649
+ LANGUAGE plpgsql AS $$
1650
+ BEGIN
1651
+ RETURN 'abc'::enum_t;
1652
+ END;
1653
+ $$;
1654
+ ''' )
1655
+
1656
+ try :
1657
+ result = await self .con .fetchval ('''SELECT return_enum()''' )
1658
+ self .assertEqual (result , 'abc' )
1659
+
1660
+ finally :
1661
+ await self .con .execute ('''
1662
+ DROP FUNCTION return_enum();
1663
+ DROP TYPE enum_t;
1664
+ ''' )
1665
+
1627
1666
async def test_no_result (self ):
1628
1667
st = await self .con .prepare ('rollback' )
1629
1668
self .assertTupleEqual (st .get_attributes (), ())
0 commit comments