Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions doris_mcp_server/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,9 @@ async def execute(self, sql: str, params: tuple | None = None, auth_context=None
async with self.connection.cursor(aiomysql.DictCursor) as cursor:
await cursor.execute(sql, params)

# Check if it's a query statement (statement that returns result set)
# FIX for Issue #62 Bug 5: Added WITH support for Common Table Expressions (CTE)
sql_upper = sql.strip().upper()
if (sql_upper.startswith("SELECT") or
sql_upper.startswith("SHOW") or
sql_upper.startswith("DESCRIBE") or
sql_upper.startswith("DESC") or
sql_upper.startswith("EXPLAIN") or
sql_upper.startswith("WITH")): # FIX: Support CTE queries
# cursor.description is set by the DB driver for any statement that returns rows,
# avoiding a brittle hardcoded keyword list (e.g. missing WITH/CTE, comments before keywords).
if cursor.description:
data = await cursor.fetchall()
row_count = len(data)
else:
Expand Down