Fixed an issue where filtering on a view caused an error. #8630

pull/8631/head
Akshay Joshi 2025-04-09 19:00:32 +05:30
parent 4c56e49c66
commit 31b1af2f84
2 changed files with 6 additions and 50 deletions

View File

@ -34,4 +34,5 @@ Bug fixes
| `Issue #8443 <https://github.com/pgadmin-org/pgadmin4/issues/8443>`_ - Fixed an issue where the debugger hangs when stepping into nested function/procedure. | `Issue #8443 <https://github.com/pgadmin-org/pgadmin4/issues/8443>`_ - Fixed an issue where the debugger hangs when stepping into nested function/procedure.
| `Issue #8497 <https://github.com/pgadmin-org/pgadmin4/issues/8497>`_ - Fixed an issue where the scroll position in the Object Explorer was not retained when switching workspaces. | `Issue #8497 <https://github.com/pgadmin-org/pgadmin4/issues/8497>`_ - Fixed an issue where the scroll position in the Object Explorer was not retained when switching workspaces.
| `Issue #8556 <https://github.com/pgadmin-org/pgadmin4/issues/8556>`_ - Ensure that graph data is updated even when the Dashboard tab is inactive. | `Issue #8556 <https://github.com/pgadmin-org/pgadmin4/issues/8556>`_ - Ensure that graph data is updated even when the Dashboard tab is inactive.
| `Issue #8572 <https://github.com/pgadmin-org/pgadmin4/issues/8572>`_ - Fixed an issue where Ctrl/Cmd+A in cell editor would select all rows. | `Issue #8572 <https://github.com/pgadmin-org/pgadmin4/issues/8572>`_ - Fixed an issue where Ctrl/Cmd+A in cell editor would select all rows.
| `Issue #8630 <https://github.com/pgadmin-org/pgadmin4/issues/8630>`_ - Fixed an issue where filtering on a view caused an error.

View File

@ -369,7 +369,7 @@ class GridCommand(BaseCommand, SQLFilter, FetchedRowTracker):
def get_primary_keys(self, *args, **kwargs): def get_primary_keys(self, *args, **kwargs):
return None, None 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 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 all_columns: List of all the column for given object which will
be used to fill columns options 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 = [] all_sorted_columns = []
data_sorting = self.get_data_sorting() 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']: # If user has custom data sorting then pass as it is.
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 data_sorting and len(data_sorting) > 0: if data_sorting and len(data_sorting) > 0:
all_sorted_columns = data_sorting all_sorted_columns = data_sorting
return all_sorted_columns, all_columns return all_sorted_columns
def save(self, changed_data, default_conn=None): def save(self, changed_data, default_conn=None):
return forbidden( return forbidden(
@ -563,27 +539,6 @@ class TableCommand(GridCommand):
return pk_names, primary_keys 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): def can_edit(self):
return True return True
@ -865,7 +820,7 @@ class QueryToolCommand(BaseCommand, FetchedRowTracker):
def get_sql(self, default_conn=None): def get_sql(self, default_conn=None):
return None return None
def get_all_columns_with_order(self, default_conn=None): def get_all_columns_with_order(self):
return None return None
def get_primary_keys(self): def get_primary_keys(self):