mortalBibo opened a new pull request, #87:
URL: https://github.com/apache/doris-mcp-server/pull/87

   Closes #86. Continues #75.
   
   ## Two related bugs, one root cause
   
   `sql.startswith("SELECT")` at two callsites fails when SQL begins with a 
leading `--` or `/* */` comment.
   
   | Callsite | Symptom |
   |---|---|
   | `db.py:100` | `data: []` with `row_count > 0` |
   | `query_executor.py:689` | `LIMIT {max_rows}` silently skipped |
   
   ## Fixes
   
   1. **`db.py`** (commit by @jonasbrami, cherry-picked from #75): use 
`cursor.description` instead of parsing SQL text. PEP 249 guarantees the driver 
populates it for any result-returning statement, eliminating the 
"missing-from-whitelist" bug class (#62 Bug 5, comments, parenthesized SELECT, 
etc.).
   
   2. **`query_executor.py`**: this runs before `cursor.execute`, so 
`cursor.description` isn't available. Use a small helper 
(`get_first_sql_keyword`) that strips leading comments before extracting the 
first keyword.
   
   ## Regression tests (addresses @catpineapple's feedback on #75)
   
   `TestExecuteResultSetDetection` pins the user-facing contract: any SQL the 
driver reports as producing a result set must return its rows, regardless of 
phrasing. Parametrized across 12 positive cases (`--` comment, `/* */`, 
multiline block, mixed whitespace, parenthesized, CTE, comment+CTE, `SHOW`, 
`DESC`, `EXPLAIN`, …) and 4 negative cases 
(`INSERT`/`UPDATE`/`DELETE`/`CREATE`).
   
   Tests assert on the contract, not the implementation — they'll continue to 
guard whatever heuristic future maintainers choose.
   
   ## Note to @jonasbrami
   
   Your commit is preserved as-is at the base of this branch. If you'd prefer 
to continue #75 yourself, I'll close this PR — just let me know.


-- 
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]

Reply via email to