Skip to content

Commit f113f92

Browse files
fix: convert memoryview to bytes for PostgreSQL blob unpacking
psycopg2 returns bytea columns as memoryview objects, which lack the startswith() method needed by the blob decompression code. Convert to bytes at the start of unpack() for compatibility. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c795c3a commit f113f92

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/datajoint/blob.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ def squeeze(self, array: np.ndarray, convert_to_scalar: bool = True) -> np.ndarr
149149
return array.item() if array.ndim == 0 and convert_to_scalar else array
150150

151151
def unpack(self, blob):
152+
# PostgreSQL returns bytea as memoryview; convert to bytes for string operations
153+
if isinstance(blob, memoryview):
154+
blob = bytes(blob)
152155
self._blob = blob
153156
try:
154157
# decompress

0 commit comments

Comments
 (0)