ephraimbuddy commented on code in PR #31486:
URL: https://github.com/apache/airflow/pull/31486#discussion_r1205870067
##########
airflow/utils/db.py:
##########
@@ -1004,15 +1010,17 @@ def reflect_tables(tables: list[Base | str] | None,
session):
"""
import sqlalchemy.schema
- metadata = sqlalchemy.schema.MetaData(session.bind)
+ bind = session.bind
+ metadata = sqlalchemy.schema.MetaData()
+ metadata.bind = bind
if tables is None:
- metadata.reflect(resolve_fks=False)
+ metadata.reflect(bind=bind, resolve_fks=False)
else:
for tbl in tables:
try:
table_name = tbl if isinstance(tbl, str) else tbl.__tablename__
- metadata.reflect(only=[table_name], extend_existing=True,
resolve_fks=False)
+ metadata.reflect(bind=bind, only=[table_name],
extend_existing=True, resolve_fks=False)
Review Comment:
What happened was that the metadata that was returned by the function was
not bound to any database. The other binds are for the reflect methods. Despite
the session being bound to metadata, they still want the bind to happen on its
method
--
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]