codeant-ai-for-open-source[bot] commented on code in PR #41492:
URL: https://github.com/apache/superset/pull/41492#discussion_r3664418925


##########
superset/db_engine_specs/mssql.py:
##########
@@ -53,6 +53,11 @@ class MssqlEngineSpec(BaseEngineSpec):
     engine = "mssql"
     engine_name = "Microsoft SQL Server"
 
+    # SQL Server quotes identifiers with square brackets; only the closing 
bracket
+    # needs escaping (by doubling).
+    identifier_quote_start: str = "["
+    identifier_quote_end: str = "]"

Review Comment:
   **Suggestion:** The new class attributes are inherited by 
`SybaseEngineSpec`, which subclasses `MssqlEngineSpec` and also advertises the 
`sybase_sqlany` alias. SQL Lab will therefore insert `[table name]` for 
Sybase/SQL Anywhere connections even though those dialects use their own 
identifier preparer and do not necessarily accept SQL Server square-bracket 
quoting, causing autocomplete-generated queries for quoted table names to fail. 
Override the quote characters in the Sybase spec or expose them from the actual 
SQLAlchemy dialect instead of defining them on the shared MSSQL parent. [api 
mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Sybase autocomplete queries may fail for quoted table names.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Configure a database using the `SybaseEngineSpec` defined at
   `superset/db_engine_specs/sybase.py:22`; this class inherits 
`MssqlEngineSpec` and
   declares the `sybase_sqlany` alias at 
`superset/db_engine_specs/sybase.py:30-32`.
   
   2. Request the database metadata used by SQL Lab.
   `BaseEngineSpec.get_public_information()` at 
`superset/db_engine_specs/base.py:2657-2674`
   reads the inherited `identifier_quote_start` and `identifier_quote_end`, so 
Sybase and
   `sybase_sqlany` connections advertise `{start: "[", end: "]"}`.
   
   3. Open SQL Lab for that connection and expand a table list. `useKeywords()` 
at
   
`superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.ts:121-126` 
reads the
   advertised quote characters, and `insertMatch()` at
   
`superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.ts:154-161` 
passes them
   to `quoteIdentifier()` for any non-simple table name.
   
   4. Select a Sybase or SQL Anywhere table whose name requires quoting, such 
as one
   containing spaces. The autocomplete inserts `[table name]`, because the 
attributes added
   at `superset/db_engine_specs/mssql.py:56-59` are inherited, while the Sybase 
engine spec
   has no dialect-specific override; databases whose dialect does not accept 
SQL Server
   square-bracket delimiters receive invalid SQL.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a690da5174d145438292edf71d7a7a30&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=a690da5174d145438292edf71d7a7a30&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/db_engine_specs/mssql.py
   **Line:** 56:59
   **Comment:**
        *Api Mismatch: The new class attributes are inherited by 
`SybaseEngineSpec`, which subclasses `MssqlEngineSpec` and also advertises the 
`sybase_sqlany` alias. SQL Lab will therefore insert `[table name]` for 
Sybase/SQL Anywhere connections even though those dialects use their own 
identifier preparer and do not necessarily accept SQL Server square-bracket 
quoting, causing autocomplete-generated queries for quoted table names to fail. 
Override the quote characters in the Sybase spec or expose them from the actual 
SQLAlchemy dialect instead of defining them on the shared MSSQL parent.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41492&comment_hash=f3b6c02afebc1489d2873117f49e1fbd036d407869198669fb21bb218352df22&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41492&comment_hash=f3b6c02afebc1489d2873117f49e1fbd036d407869198669fb21bb218352df22&reaction=dislike'>👎</a>



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