Skip to content

Commit 15dd9a8

Browse files
dstandishjedcunningham
authored andcommitted
Resolve deprecation warning re Table.exists() (#26616)
The deprecation warning tells us we need to change Table.exists() to Inspector.has_table(). It turns out we're already using the right method, but we weren't passing it the right object. It wants a table name but we were giving it a table. (cherry picked from commit 2388bd7)
1 parent 5e990fd commit 15dd9a8

15 files changed

+15
-64
lines changed

airflow/compat/sqlalchemy.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

airflow/migrations/versions/0001_1_5_0_current_schema.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626

2727
import sqlalchemy as sa
2828
from alembic import op
29-
from sqlalchemy import func
29+
from sqlalchemy import func, inspect
3030

31-
from airflow.compat.sqlalchemy import inspect
3231
from airflow.migrations.db_types import StringID
3332

3433
# revision identifiers, used by Alembic.

airflow/migrations/versions/0002_1_5_0_create_is_encrypted.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626

2727
import sqlalchemy as sa
2828
from alembic import op
29-
30-
from airflow.compat.sqlalchemy import inspect
29+
from sqlalchemy import inspect
3130

3231
# revision identifiers, used by Alembic.
3332
revision = '1507a7289a2f'

airflow/migrations/versions/0023_1_8_2_add_max_tries_column_to_task_instance.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525

2626
import sqlalchemy as sa
2727
from alembic import op
28-
from sqlalchemy import Column, Integer, String
28+
from sqlalchemy import Column, Integer, String, inspect
2929
from sqlalchemy.ext.declarative import declarative_base
3030

3131
from airflow import settings
32-
from airflow.compat.sqlalchemy import inspect
3332
from airflow.models import DagBag
3433

3534
# revision identifiers, used by Alembic.

airflow/migrations/versions/0028_1_10_0_add_kubernetes_resource_checkpointing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525

2626
import sqlalchemy as sa
2727
from alembic import op
28-
29-
from airflow.compat.sqlalchemy import inspect
28+
from sqlalchemy import inspect
3029

3130
# revision identifiers, used by Alembic.
3231
revision = '33ae817a1ff4'

airflow/migrations/versions/0057_1_10_13_add_fab_tables.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626

2727
import sqlalchemy as sa
2828
from alembic import op
29-
30-
from airflow.compat.sqlalchemy import inspect
29+
from sqlalchemy import inspect
3130

3231
# revision identifiers, used by Alembic.
3332
revision = '92c57b58940d'

airflow/migrations/versions/0058_1_10_13_increase_length_of_fab_ab_view_menu_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
import sqlalchemy as sa
2828
from alembic import op
29+
from sqlalchemy import inspect
2930

30-
from airflow.compat.sqlalchemy import inspect
3131
from airflow.migrations.db_types import StringID
3232

3333
# revision identifiers, used by Alembic.

airflow/migrations/versions/0059_2_0_0_drop_user_and_chart.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525

2626
import sqlalchemy as sa
2727
from alembic import op
28+
from sqlalchemy import inspect
2829
from sqlalchemy.dialects import mysql
2930

30-
from airflow.compat.sqlalchemy import inspect
31-
3231
# revision identifiers, used by Alembic.
3332
revision = 'cf5dc11e79ad'
3433
down_revision = '03afc6b6f902'

airflow/migrations/versions/0060_2_0_0_remove_id_column_from_xcom.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
from collections import defaultdict
2828

2929
from alembic import op
30-
from sqlalchemy import Column, Integer
31-
32-
from airflow.compat.sqlalchemy import inspect
30+
from sqlalchemy import Column, Integer, inspect
3331

3432
# revision identifiers, used by Alembic.
3533
revision = 'bbf4a7ad0465'

airflow/migrations/versions/0062_2_0_0_add_dagrun_run_type.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727

2828
import sqlalchemy as sa
2929
from alembic import op
30-
from sqlalchemy import Column, Integer, String
30+
from sqlalchemy import Column, Integer, String, inspect
3131
from sqlalchemy.ext.declarative import declarative_base
3232

33-
from airflow.compat.sqlalchemy import inspect
3433
from airflow.utils.types import DagRunType
3534

3635
# revision identifiers, used by Alembic.

airflow/migrations/versions/0065_2_0_0_update_schema_for_smart_sensor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626

2727
import sqlalchemy as sa
2828
from alembic import op
29-
from sqlalchemy import func
29+
from sqlalchemy import func, inspect
3030

31-
from airflow.compat.sqlalchemy import inspect
3231
from airflow.migrations.db_types import TIMESTAMP, StringID
3332

3433
# revision identifiers, used by Alembic.

airflow/migrations/versions/0068_2_0_0_drop_kuberesourceversion_and_.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626

2727
import sqlalchemy as sa
2828
from alembic import op
29-
30-
from airflow.compat.sqlalchemy import inspect
29+
from sqlalchemy import inspect
3130

3231
# revision identifiers, used by Alembic.
3332
revision = 'bef4f3d11e8b'

airflow/utils/db.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
import airflow
3535
from airflow import settings
36-
from airflow.compat.sqlalchemy import has_table
3736
from airflow.configuration import conf
3837
from airflow.exceptions import AirflowException
3938
from airflow.models import import_all_models
@@ -1643,7 +1642,7 @@ def drop_airflow_models(connection):
16431642

16441643
migration_ctx = MigrationContext.configure(connection)
16451644
version = migration_ctx._version
1646-
if has_table(connection, version):
1645+
if inspect(connection).has_table(version.name):
16471646
version.drop(connection)
16481647

16491648

airflow/www/fab_security/sqla/manager.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222
from flask_appbuilder import const as c
2323
from flask_appbuilder.models.sqla import Base
2424
from flask_appbuilder.models.sqla.interface import SQLAInterface
25-
from sqlalchemy import and_, func, literal
25+
from sqlalchemy import and_, func, inspect, literal
2626
from sqlalchemy.orm.exc import MultipleResultsFound
2727
from werkzeug.security import generate_password_hash
2828

29-
from airflow.compat import sqlalchemy as sqla_compat
3029
from airflow.www.fab_security.manager import BaseSecurityManager
3130
from airflow.www.fab_security.sqla.models import (
3231
Action,
@@ -99,7 +98,7 @@ def register_views(self):
9998
def create_db(self):
10099
try:
101100
engine = self.get_session.get_bind(mapper=None, clause=None)
102-
inspector = sqla_compat.inspect(engine)
101+
inspector = inspect(engine)
103102
if "ab_user" not in inspector.get_table_names():
104103
log.info(c.LOGMSG_INF_SEC_NO_DB)
105104
Base.metadata.create_all(engine)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
866390aad1d155c75b4283c4d50ff56fb1f210f21dcd0e0955984bd08f26ac5c
1+
543fe0db520047b59d9d036b17d54b07f1031a2b6ef1f46dcd2ae970f14ab0e6

0 commit comments

Comments
 (0)