Ensure that pgAdmin4 should work properly with psycopg2 v2.8. Fixes #4143

This commit is contained in:
Khushboo Vashi 2019-04-08 17:49:50 +05:30 committed by Akshay Joshi
parent 84ecffa4d9
commit c21ea3c342
3 changed files with 27 additions and 4 deletions

View File

@ -2,7 +2,7 @@
Version 4.5
***********
Release date: 2019-05-02
Release date: 2019-04-10
This release contains a number of new features and fixes reported since the
release of pgAdmin4 4.4.
@ -15,5 +15,8 @@ Features
Bug fixes
*********
| `Bug #2214 <https://redmine.postgresql.org/issues/2214>`_ - Fixed 'Change Password' issue for SCRAM authentication.
| `Bug #3656 <https://redmine.postgresql.org/issues/3656>`_ - Ensure that two consecutive SELECT statements should work properly.
| `Bug #4131 <https://redmine.postgresql.org/issues/4131>`_ - Relabel the Save button on the datagrid text editor to avoid confusion with the actual Save button that updates the database.
| `Bug #4142 <https://redmine.postgresql.org/issues/4142>`_ - Added recommended ESLinter checks.
| `Bug #4142 <https://redmine.postgresql.org/issues/4142>`_ - Added recommended ESLinter checks.
| `Bug #4143 <https://redmine.postgresql.org/issues/4143>`_ - Ensure that pgAdmin4 should work properly with psycopg2 v2.8

View File

@ -21,7 +21,7 @@ sqlparse==0.2.4
WTForms==2.2.1
Flask-Paranoid==0.2.0
psutil==5.5.1
psycopg2>=2.7.7
psycopg2>=2.8
python-dateutil>=2.8.0
htmlmin==0.1.12
Flask-HTMLmin==1.5.0

View File

@ -18,6 +18,8 @@ try:
except ImportError:
from ordereddict import OrderedDict
import psycopg2
from psycopg2.extensions import cursor as _cursor, encodings
from .encoding import configureDriverEncodings
@ -91,7 +93,25 @@ class _WrapperColumn(object):
Generates an OrderedDict from the fields of the original objects
with avoiding the duplicate name.
"""
ores = OrderedDict(self.orig_col._asdict())
# In psycopg2 2.8, the description of one result column,
# exposed as items of the cursor.description sequence.
# Before psycopg2 2.8 the description attribute was a sequence
# of simple tuples or namedtuples.
if psycopg2.__version__.find('2.8') != -1:
ores = OrderedDict()
ores['name'] = self.orig_col.name
ores['type_code'] = self.orig_col.type_code
ores['display_size'] = self.orig_col.display_size
ores['internal_size'] = self.orig_col.internal_size
ores['precision'] = self.orig_col.precision
ores['scale'] = self.orig_col.scale
ores['null_ok'] = self.orig_col.null_ok
ores['table_oid'] = self.orig_col.table_oid
ores['table_column'] = self.orig_col.table_column
else:
ores = OrderedDict(self.orig_col._asdict())
name = ores['name']
if self.dummy_name:
ores['name'] = self.dummy_name