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: unexpected commit causes pytest failure #20780

Merged
merged 2 commits into from
Jul 21, 2022
Merged
Changes from all commits
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
10 changes: 5 additions & 5 deletions superset/utils/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ def get_or_create_db(
from superset.models import core as models

database = (
db.session.query(models.Database)
.filter_by(database_name=database_name)
.autoflush(False)
.first()
db.session.query(models.Database).filter_by(database_name=database_name).first()
Copy link
Member Author

Choose a reason for hiding this comment

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

Although the Select can also be placed in a transaction, it relies on the subsequent commit(), which is not useful.

)

# databases with a fixed UUID
Expand All @@ -56,8 +53,11 @@ def get_or_create_db(
database_name=database_name, uuid=uuids.get(database_name)
)
db.session.add(database)
database.set_sqlalchemy_uri(sqlalchemy_uri)
db.session.commit()

if database:
# todo: it's a bad idea to do an update in a get/create function
if database and database.sqlalchemy_uri_decrypted != sqlalchemy_uri:
database.set_sqlalchemy_uri(sqlalchemy_uri)
db.session.commit()

Expand Down