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

Enable MySQL strict mode from the scaffolding #94

Merged
merged 1 commit into from
Aug 24, 2015

Conversation

MaxGabriel
Copy link
Member

This PR would enable MySQL's strict mode for connections coming from the application. This causes MySQL to raise errors instead of silently truncating too-long data, among other changes. This PR would have prevented yesodweb/persistent#122.

Current wiki page about this: https://github.com/yesodweb/persistent/wiki/Database-Configuration#strict-mode

-- (If you enable it in your my.cnf file, you can delete this code).
let appDatabaseConf = fromYamlAppDatabaseConf { myConnInfo = (myConnInfo fromYamlAppDatabaseConf) {
MySQL.connectOptions =
( MySQL.connectOptions (myConnInfo fromYamlAppDatabaseConf)) ++ [MySQL.InitCommand "SET SESSION sql_mode = 'STRICT_ALL_TABLES';\0"]
Copy link
Member Author

Choose a reason for hiding this comment

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

The ByteString here is explicitly null-terminated to work around this issue (related PR: paul-rouse/mysql#17).

@gregwebs
Copy link
Member

looks good to me

MaxGabriel added a commit that referenced this pull request Aug 24, 2015
Enable MySQL strict mode from the scaffolding
@MaxGabriel MaxGabriel merged commit 6da533b into yesodweb:mysql Aug 24, 2015
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