-
Notifications
You must be signed in to change notification settings - Fork 21
feat(mysql): Add config option for REQUIRED_SQL_MODES. #334
Conversation
| } | ||
|
|
||
| options.master.sql_mode = options.sql_mode | ||
| options.slave.sql_mode = options.sql_mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MySQL module docs don't mention this sql_mode option, so I wasn't sure if it was doing anything, so I deleted it.
This also tweaks the implementation to preserve any existing mode flags on the connection, rather than overwriting them with just the modes from the required list.
19aed23 to
fa6d130
Compare
| .then( | ||
| assert.fail, | ||
| err => { | ||
| assert.equal(err.message, 'ER_WRONG_VALUE_FOR_VAR') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that MySQL rejects this value, is a useful test that we are actually attempting to call SET SESSION sql_mode = blah with the provided value.
philbooth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM!
| }, | ||
| requiredSQLModes: { | ||
| doc: 'Comma-separated list of SQL mode flags to enforce on each connection', | ||
| default: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, let's just not forget to actually set this at some point :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you leave it unset, it should use the hard-coded defaults from const REQUIRED_SQL_MODES; perhaps the config doc here could have made that clearer.
This also tweaks the implementation to preserve any existing mode flags on the connection, rather than overwriting them with just the modes from the required list. That's in line with how profile-server and oauth-server approach it.
@vladikoff r?