From 31b1af2f84ebf7fa8086c5da89bdbd09d9d88879 Mon Sep 17 00:00:00 2001 From: Akshay Joshi Date: Wed, 9 Apr 2025 19:00:32 +0530 Subject: [PATCH] Fixed an issue where filtering on a view caused an error. #8630 --- docs/en_US/release_notes_9_3.rst | 3 +- web/pgadmin/tools/sqleditor/command.py | 53 ++------------------------ 2 files changed, 6 insertions(+), 50 deletions(-) diff --git a/docs/en_US/release_notes_9_3.rst b/docs/en_US/release_notes_9_3.rst index 36af863a6..9d8eda7fe 100644 --- a/docs/en_US/release_notes_9_3.rst +++ b/docs/en_US/release_notes_9_3.rst @@ -34,4 +34,5 @@ Bug fixes | `Issue #8443 `_ - Fixed an issue where the debugger hangs when stepping into nested function/procedure. | `Issue #8497 `_ - Fixed an issue where the scroll position in the Object Explorer was not retained when switching workspaces. | `Issue #8556 `_ - Ensure that graph data is updated even when the Dashboard tab is inactive. - | `Issue #8572 `_ - Fixed an issue where Ctrl/Cmd+A in cell editor would select all rows. \ No newline at end of file + | `Issue #8572 `_ - Fixed an issue where Ctrl/Cmd+A in cell editor would select all rows. + | `Issue #8630 `_ - Fixed an issue where filtering on a view caused an error. \ No newline at end of file diff --git a/web/pgadmin/tools/sqleditor/command.py b/web/pgadmin/tools/sqleditor/command.py index 62f04c35e..02965b2c6 100644 --- a/web/pgadmin/tools/sqleditor/command.py +++ b/web/pgadmin/tools/sqleditor/command.py @@ -369,7 +369,7 @@ class GridCommand(BaseCommand, SQLFilter, FetchedRowTracker): def get_primary_keys(self, *args, **kwargs): return None, None - def get_all_columns_with_order(self, default_conn): + def get_all_columns_with_order(self): """ Responsible for fetching columns from given object @@ -382,38 +382,14 @@ class GridCommand(BaseCommand, SQLFilter, FetchedRowTracker): all_columns: List of all the column for given object which will be used to fill columns options """ - driver = get_driver(PG_DEFAULT_DRIVER) - if default_conn is None: - manager = driver.connection_manager(self.sid) - conn = manager.connection(did=self.did, conn_id=self.conn_id) - else: - conn = default_conn - all_sorted_columns = [] data_sorting = self.get_data_sorting() - all_columns = [] - if conn.connected(): - # Fetch the rest of the column names - query = render_template( - "/".join([self.sql_path, 'get_columns.sql']), - table_name=self.object_name, - table_nspname=self.nsp_name, - conn=conn, - ) - status, result = conn.execute_dict(query) - if not status: - raise ExecuteError(result) - for row in result['rows']: - all_columns.append(row['attname']) - else: - raise InternalServerError(SERVER_CONNECTION_CLOSED) - - # If user has custom data sorting then pass as it as it is + # If user has custom data sorting then pass as it is. if data_sorting and len(data_sorting) > 0: all_sorted_columns = data_sorting - return all_sorted_columns, all_columns + return all_sorted_columns def save(self, changed_data, default_conn=None): return forbidden( @@ -563,27 +539,6 @@ class TableCommand(GridCommand): return pk_names, primary_keys - def get_all_columns_with_order(self, default_conn=None): - """ - It is overridden method specially for Table because we all have to - fetch primary keys. - - Args: - default_conn: Connection object - - Returns: - all_sorted_columns: Sorted columns for the Grid - """ - - all_sorted_columns = [] - data_sorting = self.get_data_sorting() - - # If user has custom data sorting then pass as it is - if data_sorting and len(data_sorting) > 0: - all_sorted_columns = data_sorting - - return all_sorted_columns - def can_edit(self): return True @@ -865,7 +820,7 @@ class QueryToolCommand(BaseCommand, FetchedRowTracker): def get_sql(self, default_conn=None): return None - def get_all_columns_with_order(self, default_conn=None): + def get_all_columns_with_order(self): return None def get_primary_keys(self):