aneesh-joseph commented on a change in pull request #9973:
URL: https://github.com/apache/airflow/pull/9973#discussion_r598749733
##########
File path: airflow/models/dagcode.py
##########
@@ -147,7 +148,7 @@ def has_dag(cls, fileloc: str, session=None) -> bool:
:param session: ORM Session
"""
fileloc_hash = cls.dag_fileloc_hash(fileloc)
- return session.query(exists().where(cls.fileloc_hash ==
fileloc_hash)).scalar()
+ return session.query(literal(True)).filter(cls.fileloc_hash ==
fileloc_hash).first() is not None
Review comment:
yea so this generates an MSSQL query
```
SELECT EXISTS (SELECT *
FROM dag_code WHERE dag_code.fileloc_hash = ?) AS anon_1
```
which fails as MSSQL doesn't support exists expression in select clause
The other option was to use
```
session.query(literal(True)).filter(
session.query(cls).filter(cls.fileloc_hash ==
fileloc_hash).exists()
).scalar()
```
which worked on mssql and postgres but not on MSSQL (this MySQL bit is
fixed in a later version of SQLA)
https://github.com/sqlalchemy/sqlalchemy/issues/5481
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]