Skip to content

Commit edbbb7e

Browse files
committed
Use connection instead of session.get_bind()
1 parent 4ea473a commit edbbb7e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

airflow/utils/db.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ def resetdb(session: Session = NEW_SESSION, skip_init: bool = False):
16431643
with create_global_lock(session=session, lock=DBLocks.MIGRATIONS):
16441644
with connection.begin():
16451645
drop_airflow_models(connection)
1646-
drop_airflow_moved_tables(session)
1646+
drop_airflow_moved_tables(connection)
16471647

16481648
if not skip_init:
16491649
initdb(session=session)
@@ -1725,11 +1725,11 @@ def drop_airflow_models(connection):
17251725
version.drop(connection)
17261726

17271727

1728-
def drop_airflow_moved_tables(session):
1728+
def drop_airflow_moved_tables(connection):
17291729
from airflow.models.base import Base
17301730
from airflow.settings import AIRFLOW_MOVED_TABLE_PREFIX
17311731

1732-
tables = set(inspect(session.get_bind()).get_table_names())
1732+
tables = set(inspect(connection).get_table_names())
17331733
to_delete = [Table(x, Base.metadata) for x in tables if x.startswith(AIRFLOW_MOVED_TABLE_PREFIX)]
17341734
for tbl in to_delete:
17351735
tbl.drop(settings.engine, checkfirst=False)

tests/utils/test_db.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def test_resetdb(
230230
session_mock = MagicMock()
231231
resetdb(session_mock, skip_init=skip_init)
232232
mock_drop_airflow.assert_called_once_with(mock_connect.return_value)
233-
mock_drop_moved.assert_called_once_with(session_mock)
233+
mock_drop_moved.assert_called_once_with(mock_connect.return_value)
234234
if skip_init:
235235
mock_init.assert_not_called()
236236
else:

0 commit comments

Comments
 (0)