Permalink
Browse files

Default to 'strict mode' in MySQL

  • Loading branch information...
1 parent a9721d8 commit 4b905606e33f0adba61c2032f0972623ba40e5e5 @mipearson mipearson committed Apr 29, 2012
@@ -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
@@ -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 = [])

0 comments on commit 4b90560

Please sign in to comment.