When attempting an insert on a domain type I hit an issue where asyncpg was unable to handle the numeric[] type;
Traceback (most recent call last):
File "test.py", line 40, in <module>
asyncio.run(main())
File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "test.py", line 36, in main
await insert_num_array(conn, [1, 2])
File "test.py", line 29, in insert_num_array
await conn.execute(sql, (num_array,))
File "/home/quantumtm/src/asyncpg/asyncpg/connection.py", line 320, in execute
_, status, _ = await self._execute(
File "/home/quantumtm/src/asyncpg/asyncpg/connection.py", line 1659, in _execute
result, _ = await self.__execute(
File "/home/quantumtm/src/asyncpg/asyncpg/connection.py", line 1684, in __execute
return await self._do_execute(
File "/home/quantumtm/src/asyncpg/asyncpg/connection.py", line 1711, in _do_execute
stmt = await self._get_statement(
File "/home/quantumtm/src/asyncpg/asyncpg/connection.py", line 416, in _get_statement
settings.register_data_types(types)
File "asyncpg/protocol/settings.pyx", line 35, in asyncpg.protocol.protocol.ConnectionSettings.register_data_types
cpdef inline register_data_types(self, types):
File "asyncpg/protocol/settings.pyx", line 36, in asyncpg.protocol.protocol.ConnectionSettings.register_data_types
self._data_codecs.add_types(types)
File "asyncpg/protocol/codecs/base.pyx", line 556, in asyncpg.protocol.protocol.DataCodecConfig.add_types
elem_codec = self.declare_fallback_codec(
File "asyncpg/protocol/codecs/base.pyx", line 706, in asyncpg.protocol.protocol.DataCodecConfig.declare_fallback_codec
raise exceptions.UnsupportedClientFeatureError(
asyncpg.exceptions._base.UnsupportedClientFeatureError: unhandled standard data type 'numeric[]' (OID 1231)
importasyncioimportasyncpgfromasyncpg.connectionimportConnectionasyncdefconnect():
returnawaitasyncpg.connect(user="quantumtm", password="quantumtm", database="test", host="127.0.0.1")
asyncdefsetup(conn: Connection):
sql=""" DROP TABLE IF EXISTS test; DROP DOMAIN IF EXISTS num_array; CREATE DOMAIN num_array numeric[]; CREATE TABLE test ( num num_array ); """awaitconn.execute(sql)
asyncdefinsert_num_array(conn: Connection, num_array):
sql="INSERT INTO test (num) VALUES ($1)"awaitconn.execute(sql, (num_array,))
asyncdefmain():
conn=awaitconnect()
awaitsetup(conn)
awaitinsert_num_array(conn, [1, 2])
if__name__=='__main__':
asyncio.run(main())
the issue with a local PostgreSQL install?: N/A
uvloop?: Not tested
When attempting an insert on a domain type I hit an issue where asyncpg was unable to handle the
numeric[]type;On analysis this error can occure for any, none
str, array type.A minimal replication case is given below