MagicStack / MagicStack/asyncpg
Functions with record array paraments
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 468
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to invoke a function with a signature like this:
CREATE OR REPLACE FUNCTION "ns"."test"(p1 "ns"."my_type"[])
It results in the following exception being raised:
Traceback (most recent call last):
File "asyncpg/protocol/prepared_stmt.pyx", line 168, in asyncpg.protocol.protocol.PreparedStatementState._encode_bind_msg
File "asyncpg/protocol/codecs/base.pyx", line 206, in asyncpg.protocol.protocol.Codec.encode
File "asyncpg/protocol/codecs/array.pyx", line 115, in asyncpg.protocol.protocol.array_encode
File "asyncpg/protocol/codecs/array.pyx", line 115, in asyncpg.protocol.protocol.array_encode
TypeError: a sized iterable container expected (got type 'dict')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
buffer, _, self._exhausted = await protocol.bind_execute(
File "asyncpg/protocol/protocol.pyx", line 183, in bind_execute
File "asyncpg/protocol/prepared_stmt.pyx", line 197, in asyncpg.protocol.protocol.PreparedStatementState._encode_bind_msg
asyncpg.exceptions.DataError: invalid input for query argument $1: {'holiday_center': '123', 'observed_on':... (a sized iterable container expected (got type 'dict'))
How do I invoke such a function?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the SQL function signature and the array encoder shown in asyncpg/protocol/codecs/array.pyx, then trace how the argument reaches asyncpg/protocol/prepared_stmt.pyx. Reproduce the call with the record-array parameter and compare the accepted input shape with the reported dict error; done means the function can be invoked successfully and the behavior is covered or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100