diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2014-11-18 07:02:15 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2015-05-26 17:44:24 -0700 |
commit | 7961f4f7764a902a1f454eb324d8122037e28702 (patch) | |
tree | d9352521454b29a06da72a227c7c9d47c580fd30 /activerecord/lib | |
parent | 888744935483abfd655ed8a8661de0e2725b53bc (diff) | |
download | rails-7961f4f7764a902a1f454eb324d8122037e28702.tar.gz rails-7961f4f7764a902a1f454eb324d8122037e28702.tar.bz2 rails-7961f4f7764a902a1f454eb324d8122037e28702.zip |
If specify `strict: :default` explicitly, do not set sql_mode.
Related with #17370.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index c3206c6045..00e3d2965b 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -959,10 +959,12 @@ module ActiveRecord wait_timeout = 2147483 unless wait_timeout.is_a?(Fixnum) variables['wait_timeout'] = self.class.type_cast_config_to_integer(wait_timeout) + defaults = [':default', :default].to_set + # Make MySQL reject illegal values rather than truncating or blanking them, see # http://dev.mysql.com/doc/refman/5.6/en/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') + unless variables.has_key?('sql_mode') || defaults.include?(@config[:strict]) variables['sql_mode'] = strict_mode? ? 'STRICT_ALL_TABLES' : '' end @@ -977,7 +979,7 @@ module ActiveRecord # Gather up all of the SET variables... variable_assignments = variables.map do |k, v| - if v == ':default' || v == :default + if defaults.include?(v) "@@SESSION.#{k} = DEFAULT" # Sets the value to the global or compile default elsif !v.nil? "@@SESSION.#{k} = #{quote(v)}" |