@@ -1091,7 +1091,7 @@ async def test_extra_codec_alias(self):
1091
1091
# This should fail, as there is no binary codec for
1092
1092
# my_dec_t and text decoding of composites is not
1093
1093
# implemented.
1094
- with self .assertRaises (NotImplementedError ):
1094
+ with self .assertRaises (asyncpg . UnsupportedClientFeatureError ):
1095
1095
res = await self .con .fetchval ('''
1096
1096
SELECT ($1::my_dec_t, 'a=>1'::hstore)::rec_t AS result
1097
1097
''' , 44 )
@@ -1148,7 +1148,7 @@ def hstore_encoder(obj):
1148
1148
self .assertEqual (at [0 ].type , pt [0 ])
1149
1149
1150
1150
err = 'cannot use custom codec on non-scalar type public._hstore'
1151
- with self .assertRaisesRegex (ValueError , err ):
1151
+ with self .assertRaisesRegex (asyncpg . InterfaceError , err ):
1152
1152
await self .con .set_type_codec ('_hstore' ,
1153
1153
encoder = hstore_encoder ,
1154
1154
decoder = hstore_decoder )
@@ -1160,7 +1160,7 @@ def hstore_encoder(obj):
1160
1160
try :
1161
1161
err = 'cannot use custom codec on non-scalar type ' + \
1162
1162
'public.mytype'
1163
- with self .assertRaisesRegex (ValueError , err ):
1163
+ with self .assertRaisesRegex (asyncpg . InterfaceError , err ):
1164
1164
await self .con .set_type_codec (
1165
1165
'mytype' , encoder = hstore_encoder ,
1166
1166
decoder = hstore_decoder )
@@ -1261,13 +1261,14 @@ async def test_custom_codec_on_domain(self):
1261
1261
''' )
1262
1262
1263
1263
try :
1264
- await self .con .set_type_codec (
1265
- 'custom_codec_t' ,
1266
- encoder = lambda v : str (v ),
1267
- decoder = lambda v : int (v ))
1268
-
1269
- v = await self .con .fetchval ('SELECT $1::custom_codec_t' , 10 )
1270
- self .assertEqual (v , 10 )
1264
+ with self .assertRaisesRegex (
1265
+ asyncpg .UnsupportedClientFeatureError ,
1266
+ 'custom codecs on domain types are not supported'
1267
+ ):
1268
+ await self .con .set_type_codec (
1269
+ 'custom_codec_t' ,
1270
+ encoder = lambda v : str (v ),
1271
+ decoder = lambda v : int (v ))
1271
1272
finally :
1272
1273
await self .con .execute ('DROP DOMAIN custom_codec_t' )
1273
1274
@@ -1666,7 +1667,7 @@ async def test_unknown_type_text_fallback(self):
1666
1667
# Text encoding of ranges and composite types
1667
1668
# is not supported yet.
1668
1669
with self .assertRaisesRegex (
1669
- RuntimeError ,
1670
+ asyncpg . UnsupportedClientFeatureError ,
1670
1671
'text encoding of range types is not supported' ):
1671
1672
1672
1673
await self .con .fetchval ('''
@@ -1675,7 +1676,7 @@ async def test_unknown_type_text_fallback(self):
1675
1676
''' , ['a' , 'z' ])
1676
1677
1677
1678
with self .assertRaisesRegex (
1678
- RuntimeError ,
1679
+ asyncpg . UnsupportedClientFeatureError ,
1679
1680
'text encoding of composite types is not supported' ):
1680
1681
1681
1682
await self .con .fetchval ('''
@@ -1847,7 +1848,7 @@ async def test_custom_codec_large_oid(self):
1847
1848
1848
1849
expected_oid = self .LARGE_OID
1849
1850
if self .server_version >= (11 , 0 ):
1850
- # PostgreSQL 11 automatically create a domain array type
1851
+ # PostgreSQL 11 automatically creates a domain array type
1851
1852
# _before_ the domain type, so the expected OID is
1852
1853
# off by one.
1853
1854
expected_oid += 1
@@ -1858,14 +1859,5 @@ async def test_custom_codec_large_oid(self):
1858
1859
v = await self .con .fetchval ('SELECT $1::test_domain_t' , 10 )
1859
1860
self .assertEqual (v , 10 )
1860
1861
1861
- # Test that custom codec logic handles large OIDs
1862
- await self .con .set_type_codec (
1863
- 'test_domain_t' ,
1864
- encoder = lambda v : str (v ),
1865
- decoder = lambda v : int (v ))
1866
-
1867
- v = await self .con .fetchval ('SELECT $1::test_domain_t' , 10 )
1868
- self .assertEqual (v , 10 )
1869
-
1870
1862
finally :
1871
1863
await self .con .execute ('DROP DOMAIN test_domain_t' )
0 commit comments