uranusjr commented on code in PR #32883:
URL: https://github.com/apache/airflow/pull/32883#discussion_r1299807954


##########
airflow/www/security.py:
##########
@@ -358,16 +356,15 @@ def get_accessible_dag_ids(
             if (permissions.ACTION_CAN_EDIT in user_actions and 
self.can_edit_all_dags(user)) or (
                 permissions.ACTION_CAN_READ in user_actions and 
self.can_read_all_dags(user)
             ):
-                return {dag.dag_id for dag in session.query(DagModel.dag_id)}
-            user_query = (
-                session.query(User)
+                return {dag.dag_id for dag in 
session.execute(select(DagModel.dag_id))}
+            user_query = session.scalar(
+                select(User)
                 .options(
                     joinedload(User.roles)
                     .subqueryload(Role.permissions)
                     .options(joinedload(Permission.action), 
joinedload(Permission.resource))
                 )
-                .filter(User.id == user.id)
-                .first()
+                .where(User.id == user.id)

Review Comment:
   Same as `DagModel`, it should not possible for this query to return more 
than one row since `User.id` is the primary key.



##########
airflow/www/security.py:
##########
@@ -358,16 +356,15 @@ def get_accessible_dag_ids(
             if (permissions.ACTION_CAN_EDIT in user_actions and 
self.can_edit_all_dags(user)) or (
                 permissions.ACTION_CAN_READ in user_actions and 
self.can_read_all_dags(user)
             ):
-                return {dag.dag_id for dag in session.query(DagModel.dag_id)}
-            user_query = (
-                session.query(User)
+                return {dag.dag_id for dag in 
session.execute(select(DagModel.dag_id))}
+            user_query = session.scalar(
+                select(User)
                 .options(
                     joinedload(User.roles)
                     .subqueryload(Role.permissions)
                     .options(joinedload(Permission.action), 
joinedload(Permission.resource))
                 )
-                .filter(User.id == user.id)
-                .first()
+                .where(User.id == user.id)

Review Comment:
   Same as `DagModel`, it should not be possible for this query to return more 
than one row since `User.id` is the primary key.



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

Reply via email to