Skip to content

Commit e545c45

Browse files
committed
elvis: wip
1 parent 9d8a1c0 commit e545c45

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

asyncpg/protocol/codecs/record.pyx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,25 @@ cdef anonymous_record_decode(ConnectionSettings settings, FRBuffer *buf):
5151
return result
5252

5353

54+
cdef anonymous_record_decode_ex(ConnectionSettings settings, FRBuffer *buf,
55+
const void *arg):
56+
return anonymous_record_decode(settings, buf)
57+
58+
59+
cdef anonymous_record_array_decode(ConnectionSettings settings, FRBuffer *buf):
60+
return array_decode(
61+
settings, buf, <decode_func_ex>&anonymous_record_decode_ex, NULL)
62+
63+
5464
cdef init_record_codecs():
5565
register_core_codec(RECORDOID,
5666
<encode_func>NULL,
5767
<decode_func>anonymous_record_decode,
5868
PG_FORMAT_BINARY)
5969

70+
register_core_codec(_RECORDOID,
71+
<encode_func>NULL,
72+
<decode_func>anonymous_record_array_decode,
73+
PG_FORMAT_BINARY)
74+
6075
init_record_codecs()

asyncpg/protocol/pgtypes.pxi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ DEF LANGUAGE_HANDLEROID = 2280
7979
DEF INTERNALOID = 2281
8080
DEF OPAQUEOID = 2282
8181
DEF ANYELEMENTOID = 2283
82+
DEF _RECORDOID = 2287
8283
DEF ANYNONARRAYOID = 2776
8384
DEF UUIDOID = 2950
8485
DEF TXID_SNAPSHOTOID = 2970
@@ -99,7 +100,7 @@ DEF EVENT_TRIGGEROID = 3838
99100
DEF REGNAMESPACEOID = 4089
100101
DEF REGROLEOID = 4096
101102

102-
cdef ARRAY_TYPES = (_TEXTOID, _OIDOID,)
103+
cdef ARRAY_TYPES = (_TEXTOID, _OIDOID, _RECORDOID,)
103104

104105
BUILTIN_TYPE_OID_MAP = {
105106
ABSTIMEOID: 'abstime',
@@ -187,6 +188,7 @@ BUILTIN_TYPE_OID_MAP = {
187188
XIDOID: 'xid',
188189
XMLOID: 'xml',
189190
_OIDOID: 'oid[]',
191+
_RECORDOID: 'record[]',
190192
_TEXTOID: 'text[]'
191193
}
192194

tests/test_codecs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,10 @@ async def test_arrays(self):
754754
r"SELECT '{}'::int[]",
755755
[]
756756
),
757+
(
758+
r"SELECT ARRAY[(1, 2)]",
759+
[(1, 2)]
760+
)
757761
]
758762

759763
for sql, expected in cases:

tools/generate_type_map.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Array types with builtin codecs, necessary for codec
1717
# bootstrap to work
1818
#
19-
_BUILTIN_ARRAYS = ('_text', '_oid')
19+
_BUILTIN_ARRAYS = ('_text', '_oid', '_record')
2020

2121
_INVALIDOID = 0
2222

0 commit comments

Comments
 (0)