Skip to content

Commit 36df6d5

Browse files
Fix an issue where using the binary cursor, utf-8 decode error comes up. #8199
1 parent a9974b4 commit 36df6d5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

web/pgadmin/utils/driver/psycopg3/typecast.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from psycopg.adapt import Loader
2121
from ipaddress import ip_address, ip_interface
2222
from psycopg._encodings import py_codecs as encodings
23+
from psycopg.pq import Format as _pq_Format
2324

2425
configure_driver_encodings(encodings)
2526

@@ -176,6 +177,12 @@ def register_binary_typecasters(connection):
176177
connection.adapters.register_loader(1001,
177178
ByteaLoader)
178179

180+
connection.adapters.register_loader(17,
181+
ByteaBinaryLoader)
182+
183+
connection.adapters.register_loader(1001,
184+
ByteaBinaryLoader)
185+
179186

180187
def register_array_to_string_typecasters(connection=None):
181188
type_array = PSYCOPG_SUPPORTED_BUILTIN_ARRAY_DATATYPES +\
@@ -212,6 +219,13 @@ def load(self, data):
212219
return 'binary data' if data is not None else None
213220

214221

222+
class ByteaBinaryLoader(Loader):
223+
format = _pq_Format.BINARY
224+
225+
def load(self, data):
226+
return 'binary data' if data is not None else None
227+
228+
215229
class TextLoaderpgAdmin(TextLoader):
216230
def load(self, data):
217231
postgres_encoding, python_encoding = get_encoding(

0 commit comments

Comments
 (0)