Skip to content

Fix handling of large type OIDs #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions asyncpg/protocol/codecs/array.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -804,23 +804,23 @@ cdef _infer_array_dims(const Py_UCS4 *array_text,
ndims[0] = 0


cdef int4_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,
const void *arg):
return int4_encode(settings, buf, obj)
cdef uint4_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,
const void *arg):
return uint4_encode(settings, buf, obj)


cdef int4_decode_ex(ConnectionSettings settings, FastReadBuffer buf,
const void *arg):
return int4_decode(settings, buf)
cdef uint4_decode_ex(ConnectionSettings settings, FastReadBuffer buf,
const void *arg):
return uint4_decode(settings, buf)


cdef arrayoid_encode(ConnectionSettings settings, WriteBuffer buf, items):
array_encode(settings, buf, items, OIDOID,
<encode_func_ex>&int4_encode_ex, NULL)
<encode_func_ex>&uint4_encode_ex, NULL)


cdef arrayoid_decode(ConnectionSettings settings, FastReadBuffer buf):
return array_decode(settings, buf, <decode_func_ex>&int4_decode_ex, NULL)
return array_decode(settings, buf, <decode_func_ex>&uint4_decode_ex, NULL)


cdef text_encode_ex(ConnectionSettings settings, WriteBuffer buf, object obj,
Expand Down
5 changes: 5 additions & 0 deletions tests/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,11 @@ async def test_custom_codec_large_oid(self):
''')
self.assertEqual(oid, 2147483648)

# Test that introspection handles large OIDs
v = await self.con.fetchval('SELECT $1::test_domain_t', 10)
self.assertEqual(v, 10)

# Test that custom codec logic handles large OIDs
await self.con.set_type_codec(
'test_domain_t',
encoder=lambda v: str(v),
Expand Down