You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "catpineapple (via GitHub)" <gi...@apache.org> on 2026/04/14 09:32:43 UTC

Re: [PR] [fix] Use cursor.description to detect result-returning queries [doris-mcp-server]

catpineapple commented on code in PR #75:
URL: https://github.com/apache/doris-mcp-server/pull/75#discussion_r3078484498


##########
doris_mcp_server/utils/db.py:
##########
@@ -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:

Review Comment:
   Minor nit: if cursor.description is not None: might read slightly more intentional. Not a blocker



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org