From: Daniele Varrazzo Date: Thu, 26 Aug 2021 01:14:32 +0000 (+0200) Subject: Verify that arrays of binary types dump correctly X-Git-Tag: 3.0.beta1~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f84cda1028b8afbe270443f930ec9eae863e60a9;p=thirdparty%2Fpsycopg.git Verify that arrays of binary types dump correctly --- diff --git a/docs/basic/adapt.rst b/docs/basic/adapt.rst index 88ea7c911..9b0f70537 100644 --- a/docs/basic/adapt.rst +++ b/docs/basic/adapt.rst @@ -236,11 +236,6 @@ Python types representing binary objects (`bytes`, `bytearray`, `memoryview`) are converted by default to :sql:`bytea` fields. By default data received is returned as `!bytes`. -.. admonition:: todo - - Make sure bytearry/memoryview work and are compsable with - arrays/composite - If you are storing large binary data in bytea fields (such as binary documents or images) you should probably use the binary format to pass and return values, otherwise binary data will undergo `ASCII escaping`__, taking some CPU diff --git a/tests/types/test_string.py b/tests/types/test_string.py index 1633090d0..bdedc6d18 100644 --- a/tests/types/test_string.py +++ b/tests/types/test_string.py @@ -240,6 +240,9 @@ def test_dump_1byte(conn, fmt_in, pytype): cur.execute(f"select %{fmt_in} = set_byte('x', 0, %s)", (obj, i)) assert cur.fetchone()[0] is True, i + cur.execute(f"select %{fmt_in} = array[set_byte('x', 0, %s)]", ([obj], i)) + assert cur.fetchone()[0] is True + @pytest.mark.parametrize("scs", ["on", "off"]) @pytest.mark.parametrize("pytype", [bytes, bytearray, memoryview, Binary])