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

Allow setting sql_mode #52

Closed
back-2-95 opened this issue Dec 18, 2024 · 2 comments · May be fixed by #53
Closed

Allow setting sql_mode #52

back-2-95 opened this issue Dec 18, 2024 · 2 comments · May be fixed by #53
Labels
enhancement New feature or request

Comments

@back-2-95
Copy link
Member

back-2-95 commented Dec 18, 2024

If MySQL server has sql_mode which has ANSI or ANSI_QUOTES, it might results double quotes in dump file instead of backticks. And this might then break importing that dump back.

Always changing sql_mode on server side is not possible or it is for some other reason blocked.

If mysqldump-php would allow setting sql_mode, then developer using this library could go around the issue.

This is possible and I tested it by adding following to src/DumpSettings.php

$this->settings['init_commands'][] = "SET SESSION sql_mode='REAL_AS_FLOAT,PIPES_AS_CONCAT,IGNORE_SPACE,ONLY_FULL_GROUP_BY,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,STRICT_ALL_TABLES'";

See Smile-SA/gdpr-dump#145 for related discussion.

@back-2-95 back-2-95 added the enhancement New feature or request label Dec 18, 2024
@back-2-95
Copy link
Member Author

I was thinking how to set this. Maybe with ENV variable as it's not like a mysqldump option.

@back-2-95
Copy link
Member Author

See comment in Smile-SA/gdpr-dump#145 (comment)

It mitigates the issue at least when using Smile-SA/gdpr-dump. I'll leave the PR open if there is need for it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant