From 4a52a71956a8d46fcb7294ac71734504bb09bcc2 Mon Sep 17 00:00:00 2001 From: S. Solomon Darnell Date: Fri, 28 Mar 2025 21:52:21 -0500 Subject: two version of R2R are here --- .../asyncpg/pgproto/codecs/jsonpath.pyx | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .venv/lib/python3.12/site-packages/asyncpg/pgproto/codecs/jsonpath.pyx (limited to '.venv/lib/python3.12/site-packages/asyncpg/pgproto/codecs/jsonpath.pyx') diff --git a/.venv/lib/python3.12/site-packages/asyncpg/pgproto/codecs/jsonpath.pyx b/.venv/lib/python3.12/site-packages/asyncpg/pgproto/codecs/jsonpath.pyx new file mode 100644 index 00000000..610b30d7 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/asyncpg/pgproto/codecs/jsonpath.pyx @@ -0,0 +1,29 @@ +# Copyright (C) 2016-present the asyncpg authors and contributors +# +# +# This module is part of asyncpg and is released under +# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0 + + +cdef jsonpath_encode(CodecContext settings, WriteBuffer buf, obj): + cdef: + char *str + ssize_t size + + as_pg_string_and_size(settings, obj, &str, &size) + + if size > 0x7fffffff - 1: + raise ValueError('string too long') + + buf.write_int32(size + 1) + buf.write_byte(1) # jsonpath format version + buf.write_cstr(str, size) + + +cdef jsonpath_decode(CodecContext settings, FRBuffer *buf): + cdef uint8_t format = (frb_read(buf, 1)[0]) + + if format != 1: + raise ValueError('unexpected jsonpath format: {}'.format(format)) + + return text_decode(settings, buf) -- cgit v1.2.3