uranusjr commented on code in PR #32883:
URL: https://github.com/apache/airflow/pull/32883#discussion_r1299803639
##########
airflow/www/security.py:
##########
@@ -243,11 +243,9 @@ def __init__(self, appbuilder) -> None:
def _get_root_dag_id(self, dag_id: str) -> str:
if "." in dag_id:
- dm = (
- self.appbuilder.get_session.query(DagModel.dag_id,
DagModel.root_dag_id)
- .filter(DagModel.dag_id == dag_id)
- .first()
- )
+ dm = self.appbuilder.get_session.execute(
+ select(DagModel.dag_id,
DagModel.root_dag_id).where(DagModel.dag_id == dag_id)
+ ).one()
Review Comment:
I think `limit(1)` probably doesn’t matter since DagModel has a primary key
on dag_id. If this query returns more than one result we’re in big trouble.
##########
airflow/www/security.py:
##########
@@ -243,11 +243,9 @@ def __init__(self, appbuilder) -> None:
def _get_root_dag_id(self, dag_id: str) -> str:
if "." in dag_id:
- dm = (
- self.appbuilder.get_session.query(DagModel.dag_id,
DagModel.root_dag_id)
- .filter(DagModel.dag_id == dag_id)
- .first()
- )
+ dm = self.appbuilder.get_session.execute(
+ select(DagModel.dag_id,
DagModel.root_dag_id).where(DagModel.dag_id == dag_id)
+ ).one()
Review Comment:
I think `limit(1)` probably doesn’t matter since DagModel has a primary key
on dag_id. If this query returns more than one result we’re in big trouble.
--
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]