korbit-ai[bot] commented on code in PR #33741: URL: https://github.com/apache/superset/pull/33741#discussion_r2139721180
########## superset/security/manager.py: ########## @@ -1957,8 +1957,10 @@ def _delete_pvm_on_sqla_event( # pylint: disable=too-many-arguments return # Delete Any Role to PVM association connection.execute( - assoc_permissionview_role.delete().where( - assoc_permissionview_role.c.permission_view_id == pvm.id + assoc_permissionview_role.c.permission_view_id.in_( + select(permission_view_menu_table.c.id).where( + permission_view_menu_table.c.view_menu_id == pvm.view_menu_id + ) ) ) Review Comment: ### Missing DELETE Clause in Role Association Deletion <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? The query attempts to delete role associations but lacks a DELETE clause in the SQLAlchemy statement, which would prevent the actual deletion from occurring. ###### Why this matters Without the DELETE clause, the query will only select the records but not delete them, leaving orphaned permission associations in the database that should have been removed. ###### Suggested change ∙ *Feature Preview* Add the DELETE clause to properly delete the role associations: ```python connection.execute( assoc_permissionview_role.delete().where( assoc_permissionview_role.c.permission_view_id.in_( select(permission_view_menu_table.c.id).where( permission_view_menu_table.c.view_menu_id == pvm.view_menu_id ) ) ) ) ``` ###### Provide feedback to improve future suggestions [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/b7d77952-25a3-4538-83bd-f6f9948849c6/upvote) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/b7d77952-25a3-4538-83bd-f6f9948849c6?what_not_true=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/b7d77952-25a3-4538-83bd-f6f9948849c6?what_out_of_scope=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/b7d77952-25a3-4538-83bd-f6f9948849c6?what_not_in_standard=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/b7d77952-25a3-4538-83bd-f6f9948849c6) </details> <sub> 💬 Looking for more details? Reply to this comment to chat with Korbit. </sub> <!--- korbi internal id:a20d1969-68e3-4cbc-827b-7923b37196e2 --> [](a20d1969-68e3-4cbc-827b-7923b37196e2) -- 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: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org