MCPcopy
hub / github.com/MagicStack/asyncpg / test_domains

Method test_domains

tests/test_codecs.py:976–1009  ·  view source on GitHub ↗

Test encoding/decoding of composite types.

(self)

Source from the content-addressed store, hash-verified

974 await self.con.execute('DROP TYPE test_composite')
975
976 async def test_domains(self):
977 """Test encoding/decoding of composite types."""
978 await self.con.execute('''
979 CREATE DOMAIN my_dom AS int
980 ''')
981
982 await self.con.execute('''
983 CREATE DOMAIN my_dom2 AS my_dom
984 ''')
985
986 try:
987 st = await self.con.prepare('''
988 SELECT 3::my_dom2
989 ''')
990 res = await st.fetchval()
991
992 self.assertEqual(res, 3)
993
994 st = await self.con.prepare('''
995 SELECT NULL::my_dom2
996 ''')
997 res = await st.fetchval()
998
999 self.assertIsNone(res)
1000
1001 at = st.get_attributes()
1002 self.assertEqual(len(at), 1)
1003 self.assertEqual(at[0].name, 'my_dom2')
1004 self.assertEqual(at[0].type.name, 'int4')
1005 self.assertEqual(at[0].type.kind, 'scalar')
1006
1007 finally:
1008 await self.con.execute('DROP DOMAIN my_dom2')
1009 await self.con.execute('DROP DOMAIN my_dom')
1010
1011 async def test_range_types(self):
1012 """Test encoding/decoding of range types."""

Callers

nothing calls this directly

Calls 4

prepareMethod · 0.80
get_attributesMethod · 0.80
executeMethod · 0.45
fetchvalMethod · 0.45

Tested by

no test coverage detected