kaxil commented on a change in pull request #14016:
URL: https://github.com/apache/airflow/pull/14016#discussion_r568280948



##########
File path: airflow/utils/session.py
##########
@@ -29,7 +29,9 @@ def create_session():
     session = settings.Session()
     try:
         yield session
-        session.commit()
+        # Only Commit is a new or a modified object exists in the session
+        if not session._is_clean():  # pylint: disable=protected-access

Review comment:
       Both the file changes are not strictly needed. Either of the two file 
changes are sufficient.
   
   In one cases we commit an empty session and in other case we don't commit a 
session if it is empty. 

##########
File path: airflow/utils/sqlalchemy.py
##########
@@ -214,6 +214,9 @@ def _validate_commit(self, _):
         if self.expected_commit:
             self.expected_commit = False
             return
+        # Don't raise error if session is clean (useful when just querying 
from DB)
+        if self.session._is_clean():  # pylint: disable=protected-access

Review comment:
       Yeah, I tried with `session.execute("update dag set is_active=False 
where dag_id='example_branch_operator'")` where `session._is_clean()` is `True` 
-- so this logic does not work -- going to close the PR




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


Reply via email to