Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Default to 'strict mode' in MySQL

  • Loading branch information...
commit 4b905606e33f0adba61c2032f0972623ba40e5e5 1 parent a9721d8
@mipearson mipearson authored
View
6 activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
@@ -253,6 +253,12 @@ def configure_connection
# By default, MySQL 'where id is null' selects the last inserted id.
# Turn this off. http://dev.rubyonrails.org/ticket/6778
variable_assignments = ['SQL_AUTO_IS_NULL=0']
+
+ # 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
+ variable_assignments << "SQL_MODE='STRICT_ALL_TABLES'"
+
encoding = @config[:encoding]
# make sure we set the encoding
View
5 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -404,6 +404,11 @@ def configure_connection
# By default, MySQL 'where id is null' selects the last inserted id.
# Turn this off. http://dev.rubyonrails.org/ticket/6778
execute("SET SQL_AUTO_IS_NULL=0", :skip_logging)
+
+ # 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
+ execute("SET SQL_MODE='STRICT_ALL_TABLES'", :skip_logging)
end
def select(sql, name = nil, binds = [])
Please sign in to comment.
Something went wrong with that request. Please try again.