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


##########
airflow/models/serialized_dag.py:
##########
@@ -142,23 +142,21 @@ def write_dag(
         # If Yes, does nothing
         # If No or the DAG does not exists, updates / writes Serialized DAG to 
DB
         if min_update_interval is not None:
-            if (
-                session.query(literal(True))
-                .filter(
+            if session.scalar(
+                select(literal(True)).where(
                     and_(
                         cls.dag_id == dag.dag_id,
                         (timezone.utcnow() - 
timedelta(seconds=min_update_interval)) < cls.last_updated,
                     )

Review Comment:
   ```suggestion
                       cls.dag_id == dag.dag_id,
                       (timezone.utcnow() - 
timedelta(seconds=min_update_interval)) < cls.last_updated,
   ```
   
   This `and_` is totally unnecessary (`where` arguements are `and_`-ed by 
default), let’s use this change to get rid of it.



##########
airflow/models/serialized_dag.py:
##########
@@ -142,23 +142,21 @@ def write_dag(
         # If Yes, does nothing
         # If No or the DAG does not exists, updates / writes Serialized DAG to 
DB
         if min_update_interval is not None:
-            if (
-                session.query(literal(True))
-                .filter(
+            if session.scalar(
+                select(literal(True)).where(
                     and_(
                         cls.dag_id == dag.dag_id,
                         (timezone.utcnow() - 
timedelta(seconds=min_update_interval)) < cls.last_updated,
                     )

Review Comment:
   ```suggestion
                       cls.dag_id == dag.dag_id,
                       (timezone.utcnow() - 
timedelta(seconds=min_update_interval)) < cls.last_updated,
   ```
   
   This `and_` is totally unnecessary (`where` arguements are `and_`-ed by 
default), let’s use this change to get rid of it.



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