mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Default to 'strict mode' in MySQL
This commit is contained in:
parent
a9721d8941
commit
4b905606e3
2 changed files with 11 additions and 0 deletions
|
@ -253,6 +253,12 @@ module ActiveRecord
|
|||
# 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 @@ module ActiveRecord
|
|||
# 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 = [])
|
||||
|
|
Loading…
Reference in a new issue