Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ libgravatar==1.0.*
paramiko==3.5.1
psutil==7.2.*
psycopg[c]==3.2.13; python_version < '3.10'
psycopg[c]==3.3.5; python_version >= '3.10'
psycopg[c]==3.3.4; python_version >= '3.10'
pyotp==2.*
python-dateutil==2.*
pytz==2026.*
Expand Down
17 changes: 15 additions & 2 deletions web/pgadmin/utils/driver/psycopg3/tests/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ class TestEncoding(BaseTestGenerator):
scenarios = [
('UTF8 maps to the utf-8 python codec',
dict(key='UTF8', expected=['utf-8', 'utf-8'])),
# psycopg >= 3.3.5 carries an ISO88591 alias in its encoding
# table, so inverting py_codecs resolves iso8859-1 to that name;
# <= 3.3.4 only has LATIN1. Both are valid PostgreSQL names for
# the same encoding, so accept either.
('LATIN1 maps to the iso8859-1 python codec',
dict(key='LATIN1', expected=['ISO88591', 'iso8859-1'])),
dict(key='LATIN1', expected=['ISO88591', 'iso8859-1'],
also_valid=['LATIN1', 'iso8859-1'])),
('SQL_ASCII falls back to the pgAdmin-only override',
dict(key='SQL_ASCII', expected=['utf-8', 'utf-8'])),
('EUC_TW falls back to the pgAdmin-only override',
Expand All @@ -43,6 +48,9 @@ class TestEncoding(BaseTestGenerator):
dict(key='ascii', expected=['SQLASCII', 'raw-unicode-escape'])),
]

# Only set by scenarios where more than one result is correct.
also_valid = None

def setUp(self):
# No DB connection needed for this test.
pass
Expand All @@ -52,7 +60,12 @@ def runTest(self):
configure_driver_encodings(encodings)

with self.app.app_context():
self.assertEqual(get_encoding(self.key), self.expected)
result = get_encoding(self.key)

if self.also_valid is None:
self.assertEqual(result, self.expected)
else:
self.assertIn(result, [self.expected, self.also_valid])

# py_codecs/pg_codecs must stay plain dicts and stay in sync,
# regardless of how psycopg represents its internal encoding
Expand Down
Loading