sadpandajoe commented on code in PR #40527: URL: https://github.com/apache/superset/pull/40527#discussion_r3494767462
########## superset/migrations/versions/2026-05-29_00-00_b4a3f2e1d0c9_fix_security_view_menu_case.py: ########## @@ -0,0 +1,122 @@ +# 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. +"""fix Security view menu case + +Revision ID: b4a3f2e1d0c9 +Revises: 31dae2559c05 +Create Date: 2026-05-29 00:00:00.000000 + +On MySQL with the default case-insensitive collation, five Superset views that +declare ``class_permission_name = "security"`` (lowercase) cause FAB to look up +or insert a view-menu entry named ``"security"``. MySQL's case-insensitive +``UNIQUE`` constraint means the lookup finds an existing ``"Security"`` row and +uses it, OR a fresh install stores ``"security"`` because that view is +registered before the FAB built-in views register ``"Security"``. + +Python string comparisons in ``sync_role_definitions`` and the menu-hiding +logic are case-sensitive, so an all-lowercase ``"security"`` row breaks the +Security menu for MySQL (and MariaDB) deployments. + +This migration normalises the row: +* If only the lowercase ``"security"`` row exists: rename it to ``"Security"``. +* If both rows exist (SQLite / PostgreSQL fresh-install with the old code): + reassign every ``ab_permission_view`` from the lowercase row to the + correctly-cased row, then delete the duplicate. +""" + +# revision identifiers, used by Alembic. +revision = "b4a3f2e1d0c9" +down_revision = "31dae2559c05" Review Comment: I believe that the down revision may be stale. I think I added the new version as of this review, but should validate before committing. ```suggestion down_revision = "78a40c08b4be" ``` -- 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]
