]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
style: define a symbolic const for null values in array
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 5 Apr 2025 09:41:21 +0000 (10:41 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 8 Apr 2025 11:59:27 +0000 (12:59 +0100)
psycopg/psycopg/types/array.py

index 2370a90dc9ceef1e7f0c61b48ef941efc008e8f2..0b9465c4f44e90ecaea889098fcf76283f3acb14 100644 (file)
@@ -33,6 +33,8 @@ _unpack_dim = cast(Callable[[Buffer, int], "tuple[int, int]"], _struct_dim.unpac
 PY_TEXT = PyFormat.TEXT
 PQ_BINARY = pq.Format.BINARY
 
+ARRAY_NULL = b"\xff\xff\xff\xff"
+
 
 class BaseListDumper(RecursiveDumper):
     element_oid = INVALID_OID
@@ -275,7 +277,7 @@ class ListBinaryDumper(BaseListDumper):
                         data.append(item)
                     else:
                         hasnull = 1
-                        data.append(b"\xff\xff\xff\xff")
+                        data.append(ARRAY_NULL)
             else:
                 for item in L:
                     if not isinstance(item, self.cls):