FrankYang0529 commented on PR #72699: URL: https://github.com/apache/airflow/pull/72699#issuecomment-5697053808
> > @pierrejeambrun @jason810496 aren't a good chunk of these better as `query.one_or_none()`? > > We will need to check the behavior of SQLA2 on the `one_or_none` method I guess. Not sure does it apply the limit under the hook. IIUC, both `session.execute(query)` or `session.scalars(query)` run the statement as written before `one_or_none()` is even called ([session.py#L2373-L2380](https://github.com/sqlalchemy/sqlalchemy/blob/rel_2_0_52/lib/sqlalchemy/orm/session.py#L2373-L2380), [session.py#L2481-L2488](https://github.com/sqlalchemy/sqlalchemy/blob/rel_2_0_52/lib/sqlalchemy/orm/session.py#L2481-L2488)). The first form calls `Result.one_or_none()`, and the second calls `ScalarResult.one_or_none()`. Both pass the same arguments to `_only_one_row()` ([result.py#L1474-L1497](https://github.com/sqlalchemy/sqlalchemy/blob/rel_2_0_52/lib/sqlalchemy/engine/result.py#L1474-L1497), [result.py#L1847-L1857](https://github.com/sqlalchemy/sqlalchemy/blob/rel_2_0_52/lib/sqlalchemy/engine/result.py#L1847-L1857)). The `_only_one_row()` function doesn't change the SQL. -- 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]
