Skip to content

Commit

Permalink
Fix geometry decoding
Browse files Browse the repository at this point in the history
It would always return the empty bytestring.

I'm guessing that the correct thing was written first, and was then
broken during refactoring.
Since the postgis tests don't run in CI yet (#558), it got missed.
  • Loading branch information
msullivan committed Dec 11, 2024
1 parent 97e08e9 commit ca197e7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gel/protocol/codecs/codecs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1164,13 +1164,17 @@ cdef geometry_encode(pgproto.CodecContext settings, WriteBuffer buf, obj):
cdef geometry_decode(pgproto.CodecContext settings, FRBuffer *buf):
cdef:
object result
ssize_t buf_len

# Just wrap the bytes into a named tuple with a single field `wkb`
descriptor = datatypes.record_desc_new(
('wkb',), <object>NULL, <object>NULL)
result = datatypes.namedtuple_new(
datatypes.namedtuple_type_new(descriptor))

elem = PyBytes_FromStringAndSize(frb_read_all(buf), buf.len)
# frb_read_all adjusts buf.len, so we need to read it out first
buf_len = buf.len
elem = PyBytes_FromStringAndSize(frb_read_all(buf), buf_len)
cpython.Py_INCREF(elem)
cpython.PyTuple_SET_ITEM(result, 0, elem)

Expand Down

0 comments on commit ca197e7

Please sign in to comment.