Hi,

PFA patch to fix the issue where code breaks when user tries to view data
on table which do not have any column(s).
RM#1677

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py
index 607d0ec..2c96dea 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -531,25 +531,28 @@ def fetch_pg_types(trans_id):
 
         # List of oid for which we need type name from pg_type
         oid = ''
-        for col in session_obj['columns_info']:
-            type_obj = session_obj['columns_info'][col]
-            oid += str(type_obj['type_code']) + ','
-
-        # Remove extra comma
-        oid = oid[:-1]
-        status, res = conn.execute_dict(
-            """SELECT oid, format_type(oid,null) as typname FROM pg_type WHERE oid IN ({0}) ORDER BY oid;
+        res = {}
+        if 'columns_info' in session_obj \
+                and session_obj['columns_info'] is not None:
+            for col in session_obj['columns_info']:
+                type_obj = session_obj['columns_info'][col]
+                oid += str(type_obj['type_code']) + ','
+
+            # Remove extra comma
+            oid = oid[:-1]
+            status, res = conn.execute_dict(
+                """SELECT oid, format_type(oid,null) as typname FROM pg_type WHERE oid IN ({0}) ORDER BY oid;
 """.format(oid))
 
-        if status:
-            # iterate through pg_types and update the type name in session object
-            for record in res['rows']:
-                for col in session_obj['columns_info']:
-                    type_obj = session_obj['columns_info'][col]
-                    if type_obj['type_code'] == record['oid']:
-                        type_obj['type_name'] = record['typname']
+            if status:
+                # iterate through pg_types and update the type name in session object
+                for record in res['rows']:
+                    for col in session_obj['columns_info']:
+                        type_obj = session_obj['columns_info'][col]
+                        if type_obj['type_code'] == record['oid']:
+                            type_obj['type_name'] = record['typname']
 
-            update_session_grid_transaction(trans_id, session_obj)
+                update_session_grid_transaction(trans_id, session_obj)
     else:
         status = False
         res = error_msg
diff --git a/web/pgadmin/tools/sqleditor/static/css/sqleditor.css b/web/pgadmin/tools/sqleditor/static/css/sqleditor.css
index 64833bd..deac360 100644
--- a/web/pgadmin/tools/sqleditor/static/css/sqleditor.css
+++ b/web/pgadmin/tools/sqleditor/static/css/sqleditor.css
@@ -407,3 +407,7 @@ input.editor-checkbox {
 .grid-canvas .new_row.error, .grid-canvas .updated_row.error {
   background: #e46b6b;
 }
+
+#datagrid div.slick-header.ui-state-default {
+  background: #2c76b4;
+}
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to