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(mysql): add dialect parameter instead of hardcoded mysql dialect #739

Merged
merged 14 commits into from
Dec 12, 2024

Conversation

nightblure
Copy link
Contributor

@nightblure nightblure commented Nov 18, 2024

closes #727

  • add parameter dialect;
  • tests fixing and add some assertions

@nightblure nightblure marked this pull request as draft November 18, 2024 21:58
@nightblure nightblure marked this pull request as ready for review November 18, 2024 22:00
@nightblure
Copy link
Contributor Author

nightblure commented Nov 19, 2024

@totallyzen hi! sorry for the unnecessary trouble but I fixed it. please look at the changes

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@3436cbf). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #739   +/-   ##
=======================================
  Coverage        ?   84.77%           
=======================================
  Files           ?       12           
  Lines           ?      670           
  Branches        ?      105           
=======================================
  Hits            ?      568           
  Misses          ?       79           
  Partials        ?       23           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -104,8 +106,9 @@ def _connect(self) -> None:
)

def get_connection_url(self) -> str:
dialect = "mysql" if self.dialect is None else f"mysql+{self.dialect}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should put this simply in the init when you set self.dialect.

It would effectively become:

self.dialect = dialect or environ.get("MYSQL_DIALECT") or "mysql"

also I think dialect="mysql+asdf" makes more sense than dialect="asdf"

Copy link
Contributor Author

@nightblure nightblure Nov 20, 2024

Choose a reason for hiding this comment

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

moving to init is a good idea

but it is inconvenient for the user to create the string "mysql+asdf"

IMO dialect is a specific extension that comes after "mysql". Why repeat “mysql” everywhere if we already know that we are connecting to mysql?

besides, someone might make a typo

Copy link
Contributor Author

@nightblure nightblure Nov 20, 2024

Choose a reason for hiding this comment

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

@totallyzen Not that this is an argument, but it was interesting to look at the current implementation of the postgresql container, and it is done according to the principle that I proposed. what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

and it is done according to the principle that I proposed. what do you think?

sure I don't mind - maybe then validate the dialect does not start with mysql (raise a ValueError) then I'm happy :)

Copy link
Contributor Author

@nightblure nightblure Nov 20, 2024

Choose a reason for hiding this comment

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

ready to make this check what proposed @balint-backmaker if you approve it @totallyzen, fine?

Copy link
Collaborator

@totallyzen totallyzen Nov 21, 2024

Choose a reason for hiding this comment

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

oops, sorry for the mix - commented from the company account and not my personal 😅
(balint-backmaker is the company account, I do not normally use that here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@totallyzen did it in last commit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@totallyzen ping)

@totallyzen
Copy link
Collaborator

hi! sorry for the delays, I'll do one more review and merge it for you.

Copy link
Collaborator

@totallyzen totallyzen left a comment

Choose a reason for hiding this comment

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

small window for error: MYSQL_DIALECT can still be mysql+something and it will break tests. But I think it's good enough like this. I'll merge and release this for you and you can raise another patch for the bug above

@totallyzen totallyzen merged commit 8d77bd3 into testcontainers:main Dec 12, 2024
15 checks passed
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.

Bug: hardcoded dialect/driver parameter in connection url in mysql container
3 participants