You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "phanikumv (via GitHub)" <gi...@apache.org> on 2023/06/27 10:37:16 UTC
[GitHub] [airflow] phanikumv commented on a diff in pull request #32177: Refactor Sqlalchemy queries to 2.0 style (Part 3)
phanikumv commented on code in PR #32177:
URL: https://github.com/apache/airflow/pull/32177#discussion_r1243526571
##########
airflow/utils/db.py:
##########
@@ -959,7 +959,9 @@ def check_conn_id_duplicates(session: Session) -> Iterable[str]:
dups = []
try:
- dups = session.query(Connection.conn_id).group_by(Connection.conn_id).having(func.count() > 1).all()
+ dups = session.execute(
+ select(Connection.conn_id).group_by(Connection.conn_id).having(func.count() > 1)
+ ).all()
Review Comment:
changed `all()` to `first()`
##########
airflow/utils/db.py:
##########
@@ -984,12 +986,11 @@ def check_username_duplicates(session: Session) -> Iterable[str]:
for model in [User, RegisterUser]:
dups = []
try:
- dups = (
- session.query(model.username) # type: ignore[attr-defined]
+ dups = session.execute(
+ select(model.username) # type: ignore[attr-defined]
.group_by(model.username) # type: ignore[attr-defined]
.having(func.count() > 1)
- .all()
- )
+ ).all()
Review Comment:
changed all() to first()
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org