diff options
| author | Claude Paroz <claude@2xlibre.net> | 2016-04-06 21:25:55 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2016-04-08 20:37:23 +0200 |
| commit | 99bec24f99d60e7f52248484ebfd7e4a02c39749 (patch) | |
| tree | aeab6d958f2c6d7935333521199583a9c1316c5a /docs | |
| parent | 1ef5a328e3b292c9809657020db080b623c3bf0f (diff) | |
[1.9.x] Fixed #15940 -- Added MySQL note about strict SQL mode
Backport of b2aab09fe9 from master.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/databases.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 94d97b1487..d1d3e04894 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -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 -------------------- |
