Closed
Description
- asyncpg version: 0.11.0
- PostgreSQL version: 9.6.2
- Python version: 3.6.1
- Platform: macOS Sierra
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?: Cython==0.25.2
- Can the issue be reproduced under both asyncio and
uvloop?:
I followed the steps to have a custom type codec for JSON as described here https://magicstack.github.io/asyncpg/current/usage.html#custom-type-conversions
It works with tables created with JSON
type, but fails for JSONB
type.
I created a new test locally (similar to test_custom_codec_override
but using jsonb
instead of json
type):
async def test_custom_codec_override_jsonb(self):
"""Test overriding core codecs."""
import json
conn = await self.cluster.connect(database='postgres', loop=self.loop)
try:
def _encoder(value):
return json.dumps(value).encode('utf-8')
def _decoder(value):
return json.loads(value.decode('utf-8'))
await conn.set_type_codec(
'jsonb', encoder=_encoder, decoder=_decoder,
schema='pg_catalog', binary=True
)
data = {'foo': 'bar', 'spam': 1}
res = await conn.fetchval('SELECT $1::jsonb', data)
self.assertEqual(data, res)
finally:
await conn.close()
This is the error returned:
======================================================================
ERROR: test_custom_codec_override_jsonb (tests.test_codecs.TestCodecs)
Test overriding core codecs.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/josepcugat/workspace/asyncpg/asyncpg/_testbase.py", line 67, in wrapper
self.loop.run_until_complete(__meth__(self, *args, **kwargs))
File "/Users/josepcugat/.pyenv/versions/3.6.1/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
return future.result()
File "/Users/josepcugat/workspace/asyncpg/tests/test_codecs.py", line 951, in test_custom_codec_override_jsonb
res = await conn.fetchval('SELECT $1::jsonb', data)
File "/Users/josepcugat/workspace/asyncpg/asyncpg/connection.py", line 331, in fetchval
data = await self._execute(query, args, 1, timeout)
File "/Users/josepcugat/workspace/asyncpg/asyncpg/connection.py", line 997, in _execute
return await self._do_execute(query, executor, timeout)
File "/Users/josepcugat/workspace/asyncpg/asyncpg/connection.py", line 1018, in _do_execute
result = await executor(stmt, None)
File "asyncpg/protocol/protocol.pyx", line 189, in bind_execute (asyncpg/protocol/protocol.c:60713)
return await self._new_waiter(timeout)
asyncpg.exceptions.InternalServerError: unsupported jsonb version number 123
----------------------------------------------------------------------
Metadata
Metadata
Assignees
Labels
No labels