From a0bbc7371d25aef67002f8c1e1d11636bd7796b9 Mon Sep 17 00:00:00 2001 From: pravesh-sharma Date: Wed, 30 Apr 2025 16:16:10 +0530 Subject: [PATCH 1/2] Fixed an issue where an error was displayed when a table was dropped while a query was running. #6564 --- .../tools/sqleditor/utils/get_column_types.py | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/web/pgadmin/tools/sqleditor/utils/get_column_types.py b/web/pgadmin/tools/sqleditor/utils/get_column_types.py index d23e1c9140b..03d8292c571 100644 --- a/web/pgadmin/tools/sqleditor/utils/get_column_types.py +++ b/web/pgadmin/tools/sqleditor/utils/get_column_types.py @@ -52,31 +52,32 @@ def get_columns_types(is_query_tool, columns_info, table_oid, conn, has_oids, col_type['display_size'] = col['display_size'] column_types[col['name']] = col_type - if not is_query_tool: - col_type['not_null'] = col['not_null'] = \ - rset['rows'][key]['not_null'] + if rset['rows']: + if not is_query_tool: + col_type['not_null'] = col['not_null'] = \ + rset['rows'][key]['not_null'] - col_type['has_default_val'] = \ - col['has_default_val'] = \ - rset['rows'][key]['has_default_val'] + col_type['has_default_val'] = \ + col['has_default_val'] = \ + rset['rows'][key]['has_default_val'] - col_type['seqtypid'] = col['seqtypid'] = \ - rset['rows'][key]['seqtypid'] + col_type['seqtypid'] = col['seqtypid'] = \ + rset['rows'][key]['seqtypid'] - else: - for row in rset['rows']: - if row['oid'] == col['table_column']: - col_type['not_null'] = col['not_null'] = row['not_null'] + else: + for row in rset['rows']: + if row['oid'] == col['table_column']: + col_type['not_null'] = col['not_null'] = row['not_null'] - col_type['has_default_val'] = \ - col['has_default_val'] = row['has_default_val'] + col_type['has_default_val'] = \ + col['has_default_val'] = row['has_default_val'] - col_type['seqtypid'] = col['seqtypid'] = row['seqtypid'] - break + col_type['seqtypid'] = col['seqtypid'] = row['seqtypid'] + break - else: - col_type['not_null'] = col['not_null'] = None - col_type['has_default_val'] = col['has_default_val'] = None - col_type['seqtypid'] = col['seqtypid'] = None + else: + col_type['not_null'] = col['not_null'] = None + col_type['has_default_val'] = col['has_default_val'] = None + col_type['seqtypid'] = col['seqtypid'] = None return column_types From d0bf41ea9124513d8a57f0d2a719a493131bf864 Mon Sep 17 00:00:00 2001 From: pravesh-sharma Date: Wed, 30 Apr 2025 17:35:37 +0530 Subject: [PATCH 2/2] Fixed pep8 issue --- .../tools/sqleditor/utils/get_column_types.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/pgadmin/tools/sqleditor/utils/get_column_types.py b/web/pgadmin/tools/sqleditor/utils/get_column_types.py index 03d8292c571..f9624e794fd 100644 --- a/web/pgadmin/tools/sqleditor/utils/get_column_types.py +++ b/web/pgadmin/tools/sqleditor/utils/get_column_types.py @@ -67,17 +67,21 @@ def get_columns_types(is_query_tool, columns_info, table_oid, conn, has_oids, else: for row in rset['rows']: if row['oid'] == col['table_column']: - col_type['not_null'] = col['not_null'] = row['not_null'] + col_type['not_null'] = col['not_null'] = \ + row['not_null'] col_type['has_default_val'] = \ - col['has_default_val'] = row['has_default_val'] + col['has_default_val'] = \ + row['has_default_val'] - col_type['seqtypid'] = col['seqtypid'] = row['seqtypid'] + col_type['seqtypid'] = col['seqtypid'] = \ + row['seqtypid'] break else: col_type['not_null'] = col['not_null'] = None - col_type['has_default_val'] = col['has_default_val'] = None + col_type['has_default_val'] = \ + col['has_default_val'] = None col_type['seqtypid'] = col['seqtypid'] = None return column_types