]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Verify that arrays of binary types dump correctly
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 26 Aug 2021 01:14:32 +0000 (03:14 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 26 Aug 2021 01:14:32 +0000 (03:14 +0200)
docs/basic/adapt.rst
tests/types/test_string.py

index 88ea7c911cd250d8325030c3219f685d7cea88b3..9b0f705371ec6f5910e59507386be5271b1afa2c 100644 (file)
@@ -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
index 1633090d062e6c6cb14263ae52cc05cf9b2f919a..bdedc6d18bad3cd31f8b2a0fff33e93a08d63b78 100644 (file)
@@ -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])