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

If specify strict: :default explicitly, do not set sql_mode. #17654

Merged
merged 1 commit into from May 28, 2015

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Nov 17, 2014

Related with #17370.

@@ -810,7 +810,7 @@ def configure_connection
# Make MySQL reject illegal values rather than truncating or blanking them, see
# http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_strict_all_tables
# If the user has provided another value for sql_mode, don't replace it.
unless variables.has_key?('sql_mode')
if @config.has_key?(:strict) && !variables.has_key?('sql_mode')
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps check for if @config[:strict] ? What if someone passes strict: false

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, we should allow the user to pass in strict: false.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the next line is variables['sql_mode'] = strict_mode? ? 'STRICT_ALL_TABLES' : '',
when strict: true it becomes variables['sql_mode'] = 'STRICT_ALL_TABLES',
when strict: false it becomes variables['sql_mode'] = ''.

@sgrif
Copy link
Contributor

sgrif commented Nov 18, 2014

One comment, this seems fine otherwise.

@matthewd
Copy link
Member

IIUC, this changes the default behaviour so that we no longer default to strict mode. That seems not okay, and even if we do think it's a good idea, it would be 5.0 material.

@kamipo
Copy link
Member Author

kamipo commented Nov 18, 2014

Indeed, this changes the default behaviour so that we no longer default to strict mode. However, strict_mode should be specified explicitly rather than implicit default. This is because, if MySQL settings are being carried out properly by the administrator, the application should not overwrite the sql_mode. In practice, I had that do not set the sql_mode by strict: false, but no longer can do it by #16065.

@kamipo
Copy link
Member Author

kamipo commented Nov 18, 2014

It does not change the default behavior by kamipo@a7df5af. How does if this?

@kamipo kamipo changed the title If do not specify strict_mode explicitly, do not set sql_mode. If specify strict: :default explicitly, do not set sql_mode. May 27, 2015
@kamipo kamipo force-pushed the strict_mode_explicitly branch 2 times, most recently from 3b3edb8 to 7961f4f Compare May 27, 2015 17:45
@kamipo
Copy link
Member Author

kamipo commented May 27, 2015

I squashed this PR. This PR is no longer change the default behavior.

rafaelfranca added a commit that referenced this pull request May 28, 2015
If specify `strict: :default` explicitly, do not set sql_mode.
@rafaelfranca rafaelfranca merged commit c68e45d into rails:master May 28, 2015
@kamipo kamipo deleted the strict_mode_explicitly branch May 28, 2015 03:06
@chancancode
Copy link
Member

I believe this needs a CHANGELOG entry, something like this would be very helpful to understand how it works! :)

kamipo added a commit to kamipo/rails that referenced this pull request May 30, 2015
kamipo added a commit to kamipo/rails that referenced this pull request May 30, 2015
kamipo added a commit to kamipo/rails that referenced this pull request May 30, 2015
eileencodes added a commit that referenced this pull request May 30, 2015
@zzak
Copy link
Member

zzak commented Jun 1, 2015

Should this be backported?

/cc @rafaelfranca @matthewd

@rafaelfranca
Copy link
Member

Is there any workaround? If so it is better to not backport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants