DocsGPT icon indicating copy to clipboard operation
DocsGPT copied to clipboard

Bug Report: PostgresTool._execute_sql drops query results for CTEs (WITH queries), comments, and RETURNING clauses

Open puneetnith28 opened this issue 1 month ago • 2 comments

Description

In docsgpt/agents/tools/postgres.py, PostgresTool._execute_sql checks whether a query starts with SELECT to decide whether to fetch results.

This causes valid queries such as CTEs (WITH ... SELECT), commented SELECT statements, and queries with RETURNING clauses to execute without returning their actual result data.

Expected Behavior

The tool should return rows and column names whenever a query produces a result set, regardless of how the SQL statement begins.

Proposed Solution

Use cur.description is not None to detect result sets instead of checking the SQL string prefix, and add regression tests for the affected query types.

puneetnith28 avatar Oct 19 '26 20:10 puneetnith28

Hello @arc53-machine Could you please assign this issue to me!

puneetnith28 avatar Oct 19 '26 20:10 puneetnith28

@puneetnith28 you're assigned.

  • Open a PR or post progress here within 14 days; otherwise the issue goes back to other contributors.
  • Read CONTRIBUTING.md and add regression tests for CTEs, commented SELECTs, and RETURNING clauses.

Automated triage. A maintainer will follow up.

arc53-machine avatar Oct 19 '26 20:10 arc53-machine