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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]