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

feat(mysql): allow to connect with mysql driver without default behavor #3037

Merged
merged 3 commits into from
Feb 25, 2024

Conversation

darkecho731
Copy link
Contributor

Hi, I ran into some issues connecting with a MariaDB Instance behind ProxySQL (I would guess, that the Variables are not replicated correctly to the cluster).

I don't have any access to the Database or the Logs and thus can't debug that much but found out, that the only differences to other MySQL Drivers are the Parameters set after connecting to the Instance.

I have found this Issue #2389 and after hacking around a bit, I found that turning off the initialization "fixes" my problem.

This PR gives an option to disable the Default Behavior after connecting. I haven't touched the defaults, so there should be no breaking behavior.

@abonander
Copy link
Collaborator

My disposition is still the same as in #2389 (comment)

I'd prefer to add toggles/setters for the individual options, because the defaults all have specific reasons for existing.

@darkecho731
Copy link
Contributor Author

You're right, that's probably more sensitive.

I have implemented the setters (although I'm not 100% convinced about the naming) and adapted the connection behavior accordingly (although I'm using more Heap allocations to gain better readability, but I can change that to a single String again, if that is preferred).

The comment above the old implementation mentions setting the NO_ZERO_DATE and NO_ZERO_IN_DATE variables but I haven't added settings for them, as they are not added in the actual implementation.

Copy link
Collaborator

@abonander abonander left a comment

Choose a reason for hiding this comment

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

One documentation change and one API change.

sqlx-mysql/src/options/mod.rs Outdated Show resolved Hide resolved
sqlx-mysql/src/options/mod.rs Outdated Show resolved Hide resolved
sqlx-mysql/src/options/mod.rs Outdated Show resolved Hide resolved
…nnecting

docs(mysql): improve docs for options set_names and no_engine_substitution
@darkecho731
Copy link
Contributor Author

darkecho731 commented Feb 19, 2024

Thanks. I have updated the set_timezone_utc to a timezone setter and adopted the documentation improvements.

Edit: the impl Option<String> may be changed to impl Option<impl Display> to allow Some("+01:00") to be used but it's probably better to make it explicit, to prevent passing an integer or something.

Edit2: maybe impl Option<impl Into<String>>

@abonander
Copy link
Collaborator

I'm happy with this as it is.

@abonander abonander merged commit 27a4991 into launchbadge:main Feb 25, 2024
64 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.

2 participants