From 5d78f4a89ff7bd7d02d9ae8d0658ec4a4b009f74 Mon Sep 17 00:00:00 2001 From: Pravesh Sharma Date: Fri, 2 May 2025 14:12:06 +0530 Subject: [PATCH] Fix the issue where an error is displayed when a table is dropped while a query is running. #6564 --- .../tools/sqleditor/utils/get_column_types.py | 45 ++++++++++--------- 1 file changed, 25 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 d23e1c914..f9624e794 100644 --- a/web/pgadmin/tools/sqleditor/utils/get_column_types.py +++ b/web/pgadmin/tools/sqleditor/utils/get_column_types.py @@ -52,31 +52,36 @@ 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