This is an automated email from the ASF dual-hosted git repository. kaxilnaik pushed a commit to branch v1-10-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 61079d8990e714e4a5bf4522236d455ef8ce2a1c Author: Ash Berlin-Taylor <[email protected]> AuthorDate: Fri Nov 20 12:24:41 2020 +0000 Fix connection upgrade rules so they run with SQLite backend: (#12502) When testing out the ugprade check command on 1.10 with the default SQLite backend I got the following error: ``` [2020-11-20 12:10:28,248] {base.py:1372} ERROR - Error closing cursor Traceback (most recent call last): File "/home/ash/.virtualenvs/airflow-1-10/lib/python3.7/site-packages/sqlalchemy/engine/result.py", line 1284, in fetchall l = self.process_rows(self._fetchall_impl()) File "/home/ash/.virtualenvs/airflow-1-10/lib/python3.7/site-packages/sqlalchemy/engine/result.py", line 1230, in _fetchall_impl return self.cursor.fetchall() sqlite3.ProgrammingError: Cannot operate on a closed database. ``` This was caused because the `@provide_session` decorator closed the connection when the function returned, and since we were using a generator expression, we hadn't yet fetched all the rows. This changes it so the rows are fetched before returning. (cherry picked from commit cb0a2902fc7de73e5defc9ce54f5fd1429ec4fc6) --- airflow/upgrade/rules/conn_id_is_unique.py | 2 +- airflow/upgrade/rules/conn_type_is_not_nullable.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/airflow/upgrade/rules/conn_id_is_unique.py b/airflow/upgrade/rules/conn_id_is_unique.py index 8e1e474..edb53c8 100644 --- a/airflow/upgrade/rules/conn_id_is_unique.py +++ b/airflow/upgrade/rules/conn_id_is_unique.py @@ -41,5 +41,5 @@ duplicate values in conn_id column. .having(func.count() > 1) return ( 'Connection.conn_id={} is not unique.'.format(conn_id) - for conn_id in invalid_connections + for conn_id in invalid_connections.all() ) diff --git a/airflow/upgrade/rules/conn_type_is_not_nullable.py b/airflow/upgrade/rules/conn_type_is_not_nullable.py index 8f574d9..a411eb0 100644 --- a/airflow/upgrade/rules/conn_type_is_not_nullable.py +++ b/airflow/upgrade/rules/conn_type_is_not_nullable.py @@ -42,5 +42,5 @@ If you made any modifications to the table directly, make sure you don't have nu 'Connection<id={}", conn_id={}> have empty conn_type field.'.format( conn.id, conn.conn_id ) - for conn in invalid_connections + for conn in invalid_connections.all() )
