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

Unable to set empty sql_mode for MySQL #1311

Open
sda97ghb opened this issue Dec 28, 2022 · 0 comments
Open

Unable to set empty sql_mode for MySQL #1311

sda97ghb opened this issue Dec 28, 2022 · 0 comments

Comments

@sda97ghb
Copy link

sda97ghb commented Dec 28, 2022

Describe the bug
Empty connection url parameters are ignored by Tortoise.init.

To Reproduce

  1. Set connection url to something like mysql://myuser:mypass@db.host:3306/somedb?sql_mode= (empty value for sql_mode).
  2. Call Tortoise.init(...) with debug logs enabled.
  3. Get log message Created connection pool with params: {'host': 'db.host', 'port': 3306, 'user': 'myuser', 'db': 'somedb', 'autocommit': True, 'charset': 'utf8mb4', 'minsize': 1, 'maxsize': 5, 'sql_mode': 'STRICT_TRANS_TABLES'}

Expected behavior
Created connection pool with params: {'host': 'db.host', 'port': 3306, 'user': 'myuser', 'db': 'somedb', 'autocommit': True, 'charset': 'utf8mb4', 'minsize': 1, 'maxsize': 5, 'sql_mode': ''} (empty string as sql_mode).

Additional context
It seems like the problem is caused by parse_qs in expand_db_url, which sets keep_blank_values=False by default. Here https://github.com/tortoise/tortoise-orm/blob/develop/tortoise/backends/base/config_generator.py#L148.

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

No branches or pull requests

1 participant