Permalink
Browse files

Fixed #15940 -- Added MySQL note about strict SQL mode

  • Loading branch information...
claudep committed Apr 6, 2016
1 parent f9a2a7d commit b2aab09fe99b0e6e2e0357a7a794355a631c3039
Showing with 18 additions and 0 deletions.
  1. +18 −0 docs/ref/databases.txt
View
@@ -439,6 +439,24 @@ more details.
.. _MySQL option file: https://dev.mysql.com/doc/refman/5.6/en/option-files.html
.. _MySQLdb documentation: http://mysql-python.sourceforge.net/
+.. _mysql-sql-mode:
+
+Setting ``sql_mode``
+~~~~~~~~~~~~~~~~~~~~
+
+From MySQL 5.7 onwards and on fresh installs of MySQL 5.6, the default value of
+the ``sql_mode`` option contains ``STRICT_TRANS_TABLES``. That option escalates
+warnings into errors when data are truncated upon insertion, so Django highly
+recommends activating a `strict mode`_ for MySQL to prevent data loss (either
+``STRICT_TRANS_TABLES`` or ``STRICT_ALL_TABLES``).
+
+.. _strict mode: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict
+
+If you need to customize the SQL mode, you can set the ``sql_mode`` variable
+like other MySQL options: either in a config file or with the entry
+``'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"`` in the
+:setting:`OPTIONS` part of your database configuration in :setting:`DATABASES`.
+
Creating your tables
--------------------

0 comments on commit b2aab09

Please sign in to comment.