Bug Report: PostgresTool._execute_sql drops query results for CTEs (WITH queries), comments, and RETURNING clauses
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.
Hello @arc53-machine Could you please assign this issue to me!
@puneetnith28 you're assigned.
- Open a PR or post progress here within 14 days; otherwise the issue goes back to other contributors.
- Read
CONTRIBUTING.mdand add regression tests for CTEs, commented SELECTs, andRETURNINGclauses.
Automated triage. A maintainer will follow up.