pgadmin-org / pgadmin4

pgAdmin is the most popular and feature rich Open Source administration and development platform for PostgreSQL, the most advanced Open Source database in the world.
https://www.pgadmin.org
Other
2.54k stars 659 forks source link

'ViewCommand' object has no attribute 'auto_commit' #7384

Open d3xter opened 7 months ago

d3xter commented 7 months ago

Describe the bug

When changing the SELECT query of a View, no rows are displayed and "Total rows 0 of x" is shown at the bottom.

To Reproduce

Steps to reproduce the behavior:

  1. Create a simple View
  2. Right Click on the View -> View/Edit Data -> All Rows
  3. Change the query, e. g. add a "WHERE 1 = 1" at the end

Expected behavior

Rows are shown

Error message

2024-04-17 00:00:17,593: ERROR pgadmin: 'ViewCommand' object has no attribute 'auto_commit' Traceback (most recent call last): File "/usr/pgadmin4/venv/lib64/python3.12/site-packages/flask/app.py", line 1484, in full_dispatch_request rv = self.dispatch_request() ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/pgadmin4/venv/lib64/python3.12/site-packages/flask/app.py", line 1469, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(*view_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/pgadmin4/venv/lib64/python3.12/site-packages/flask_login/utils.py", line 290, in decorated_view return current_app.ensure_sync(func)(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/pgadmin4/web/pgadmin/tools/sqleditor/init.py", line 887, in start_query_tool return StartRunningQuery(blueprint, current_app.logger).execute( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/pgadmin4/web/pgadmin/tools/sqleditor/utils/start_running_query.py", line 93, in execute self.__execute_query( File "/usr/pgadmin4/web/pgadmin/tools/sqleditor/utils/start_running_query.py", line 140, in __execute_query if StartRunningQuery.is_begin_required_for_sql_query(trans_obj, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/pgadmin4/web/pgadmin/tools/sqleditor/utils/start_running_query.py", line 177, in is_begin_required_for_sql_query return (not trans_obj.auto_commit and ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'ViewCommand' object has no attribute 'auto_commit'

Screenshots

Original query: grafik

After changing the query: grafik

Desktop (please complete the following information):

mtovmassian commented 6 months ago

I got the same error while executing a request for creating a table from a select query. Example: create table foo as select * from bar; . But this error appears only when the request is executed from a View/Edit Data tab converted to a Query Tool tab. When executed directly in a Query Tool tab everything works as expected.

anilsahoo20 commented 6 months ago

Tested and verified on snapshot build: https://www.postgresql.org/ftp/pgadmin/pgadmin4/snapshots/2024-04-26/ Environment: macOs Ventura 13.5.1 Package: arm64

atloiaco commented 2 months ago

I'm getting the same error when trying to query a foreign table. 'ForeignTableCommand' object has no attribute 'auto_commit'Successfully run. Total query runtime: 141 msec.

If I run the same query in a new query tool window it runs fine and returns results. Successfully run. Total query runtime: 13 secs 726 msec.

fynrup commented 2 days ago

I do also get the same error 'ForeignTableCommand' object has no attribute 'auto_commit' with PgAdmin version 8.12, operating system Alpine Linux v3.20, Linux-5.4.0-200-generic-x86_64-with

This issue should be reopened

akshay-joshi commented 2 days ago

@khushboovashi

Can you please check this issue again with Foreign Table