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

correctly replace database name in query #7585

Merged
merged 2 commits into from
Dec 17, 2020
Merged

correctly replace database name in query #7585

merged 2 commits into from
Dec 17, 2020

Conversation

wochinge
Copy link
Contributor

@wochinge wochinge commented Dec 17, 2020

Proposed changes:

  • correctly interpolate text by using the sqlalchemy.text construct
  • make sure the database creation is only used for postgresql database
  • fix bug introduced by Poc bandit #7284

Status (please check what you already did):

  • added some tests for the functionality
  • updated the documentation
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

from sqlalchemy import create_engine

if not self.engine.dialect.name == "postgresql":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we could also use https://sqlalchemy-utils.readthedocs.io/en/latest/_modules/sqlalchemy_utils/functions/database.html#create_database but that only supports mysql in addition which doesn't seem worth to include it as extra library (login_db doesn't make sense for sqlite)

@wochinge wochinge requested a review from degiz December 17, 2020 15:31
Copy link
Contributor

@degiz degiz left a comment

Choose a reason for hiding this comment

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

Thanks a lot for a super quick fix 🙏

from sqlalchemy import create_engine

if not self.engine.dialect.name == "postgresql":
rasa.shared.utils.io.raise_warning(
f"The parameter 'login_db' can only be used with a postgres database.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems a bit a wrong place to warn about login_db, since it was passed as login_db in the constructor of SQLTrackerStore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's called from the constructor, no? And we can only safely determine the dialect once we're connected 🤷🏻

@akelad akelad merged commit 4c04739 into 2.2.x Dec 17, 2020
@akelad akelad deleted the fix-login-db branch December 17, 2020 16:22
@wochinge wochinge self-assigned this Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants