Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue where using the binary cursor, utf-8 decode error comes up. #8199 #8346

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions web/pgadmin/utils/driver/psycopg3/typecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from psycopg.adapt import Loader
from ipaddress import ip_address, ip_interface
from psycopg._encodings import py_codecs as encodings
from psycopg.pq import Format as _pq_Format

configure_driver_encodings(encodings)

Expand Down Expand Up @@ -176,6 +177,12 @@ def register_binary_typecasters(connection):
connection.adapters.register_loader(1001,
ByteaLoader)

connection.adapters.register_loader(17,
ByteaBinaryLoader)

connection.adapters.register_loader(1001,
ByteaBinaryLoader)


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


class ByteaBinaryLoader(Loader):
format = _pq_Format.BINARY

def load(self, data):
return 'binary data' if data is not None else None


class TextLoaderpgAdmin(TextLoader):
def load(self, data):
postgres_encoding, python_encoding = get_encoding(
Expand Down