[5.2] Improve behavior of MySQL flag, add modes
config
#12030
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Re-opening #12012 against 5.2 branch
This PR improves the behavior of the
strict
flag for the MySQL connector and adds a newmodes
config section for users who need more control than thestrict
flag allows.Quick example:
Setting
strict
totrue
now enables all of the default MySQL 5.7 modes rather than justSTRICT_TRANS_TABLES
.Reasoning here is that MySQL 5.7 being "strict" isn't just defined by one mode, and is really a combination of many. The
strict
config setting in this case is being treated as a convenience toggle between MySQL 5.6's "loose" behavior and MySQL 5.7's "strict" behavior.In 5.7,
STRICT_TRANS_TABLES
does include many of these other strict settings by default, likeNO_ZERO_IN_DATE
for example, but to replicate that behavior in 5.6 and below requires enabling those modes explicitly.Read this long ass confusing page for more info: http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html
Setting
strict
tofalse
now enables juset the default MySQL 5.6 modes.Prior to this PR, setting
strict
tofalse
actually removed all modes that were enabled by the database, as you can see here:$connection->prepare("set session sql_mode=''")->execute();
This PR just sets the mode to
NO_ENGINE_SUBSTITION
which was the default prior to 5.7.A new
modes
config key has been addedThis key is an array of the modes you would like to enable.
sql_mode
to""
.