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

Open
back-2-95 opened this issue Dec 18, 2024 · 1 comment
Open

Allow setting sql_mode #52

back-2-95 opened this issue Dec 18, 2024 · 1 comment
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.

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

No branches or pull requests

1 participant