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


##########
superset/migrations/versions/2026-05-08_12-05_9e1f3b8c4d2a_add_deleted_at_to_dashboards.py:
##########
@@ -0,0 +1,201 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Add deleted_at + partial unique slug index for soft-delete.
+
+Adds to the ``dashboards`` table:
+- a nullable ``deleted_at`` column for soft-delete state
+- an index ``ix_dashboards_deleted_at`` for the visibility-filter listener
+- a partial unique index ``ix_dashboards_active_slug`` enforcing slug
+  uniqueness only among active (non-soft-deleted) rows
+
+Drops:
+- the existing full unique constraint on ``slug`` (named
+  ``idx_unique_slug``, created in migration 1a48a5411020)
+
+The constraint change makes the ``slug`` field reusable after soft-delete:
+soft-deleted rows no longer reserve their slug for the lifetime of the
+row. ``RestoreDashboardCommand`` handles the reverse case (restoring a
+dashboard whose slug has since been claimed by another active row) with
+an explicit conflict error. See UPDATING.md for the user-facing change.
+
+Dialect support for the partial index:
+- PostgreSQL: native ``WHERE deleted_at IS NULL`` partial index
+- MySQL 8.0+: functional index over
+  ``(CASE WHEN deleted_at IS NULL THEN slug END)``

Review Comment:
   **Suggestion:** The migration documentation states MySQL support starts at 
`8.0+`, but the implementation correctly gates functional indexes at `8.0.13+`. 
This mismatch is misleading and can cause operators on `8.0.0–8.0.12` to expect 
partial-index behavior that will not be applied; update the comment to match 
the actual version gate. [comment mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ MySQL docs misstate partial index version support.
   - ⚠️ Operators on 8.0.0–12 may expect slug reuse.
   - ⚠️ Confusing downgrade expectations for mixed MySQL deployments.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open
   
`superset/migrations/versions/2026-05-08_12-05_9e1f3b8c4d2a_add_deleted_at_to_dashboards.py`
   and read the module docstring lines 35–40, which state `MySQL 8.0+: 
functional index over
   (CASE WHEN deleted_at IS NULL THEN slug END)`.
   
   2. In the same file, inspect `_mysql_supports_functional_index` at lines 
77–95, which
   returns `True` only when `bind.dialect.server_version_info >= (8, 0, 13)` 
and `is_mariadb`
   is False.
   
   3. Follow the upgrade flow: `upgrade()` at lines 98–102 calls
   `_replace_slug_constraint_with_partial_index(bind)`; inside
   `_replace_slug_constraint_with_partial_index` (lines 120–164), the MySQL 
branch at lines
   143–164 is guarded by `_mysql_supports_functional_index(bind)`.
   
   4. Deploy Superset on MySQL 8.0.0–8.0.12, run this migration, and observe 
that
   `_mysql_supports_functional_index` returns False so the functional partial 
index is not
   created and the legacy full unique slug constraint is retained, 
contradicting the
   docstring which advertised support for all 8.0+.
   ```
   </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=871bfed26e564de4bf7c0397393919a8&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=871bfed26e564de4bf7c0397393919a8&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/migrations/versions/2026-05-08_12-05_9e1f3b8c4d2a_add_deleted_at_to_dashboards.py
   **Line:** 37:38
   **Comment:**
        *Comment Mismatch: The migration documentation states MySQL support 
starts at `8.0+`, but the implementation correctly gates functional indexes at 
`8.0.13+`. This mismatch is misleading and can cause operators on 
`8.0.0–8.0.12` to expect partial-index behavior that will not be applied; 
update the comment to match the actual version gate.
   
   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%2F40128&comment_hash=e86d96f068385949600c9f4fffd4847beccfcc11fde796c498d8b82c03dc305c&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40128&comment_hash=e86d96f068385949600c9f4fffd4847beccfcc11fde796c498d8b82c03dc305c&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