Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dataset): handle missing database in migration #18948

Merged
merged 2 commits into from
Feb 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,14 @@ def after_insert(target: SqlaTable) -> None: # pylint: disable=too-many-locals
# table names
database = (
target.database
or session.query(Database).filter_by(id=target.database_id).one()
or session.query(Database).filter_by(id=target.database_id).first()
)
engine: Optional[Engine] = None
if database:
engine = database.get_sqla_engine(schema=target.schema)
conditional_quote = (
engine.dialect.identifier_preparer.quote if engine else lambda x: x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just skip the dataset if it has no database... it seems that this is something that shouldn't happen, and a dataset without an associated database is useless, no? Or am I missing something?

)
engine = database.get_sqla_engine(schema=target.schema)
conditional_quote = engine.dialect.identifier_preparer.quote

# create columns
columns = []
Expand Down