Dates avec des 00 et versions récentes de MySQL
RealET <[email protected]>
| Newsgroups | gmane.comp.web.spip.devel |
|---|---|
| Message-ID | <[email protected]> |
Bonjour, Développant sous WAMP 3.0.4 avec MySQL 5.7.9 je suis tombé sur l'impossibilité de rajouter un champ à la table auteurs. Erreur : Erreur SQL (1067) : Valeur par défaut invalide pour 'en_ligne' Raison : http://stackoverflow.com/questions/25349126/how-can-i-set-the-default-value-of-a-field-as-0000-00-00-000000 https://dev.mysql.com/doc/refman/5.6/en/sql-mode.html NO_ZERO_DATE The NO_ZERO_DATE mode affects whether the server permits '0000-00-00' as a valid date. Its effect also depends on whether strict SQL mode is enabled. If this mode is not enabled, '0000-00-00' is permitted and inserts produce no warning. If this mode is enabled, '0000-00-00' is permitted and inserts produce a warning. If this mode and strict mode are enabled, '0000-00-00' is not permitted and inserts produce an error, unless IGNORE is given as well. For INSERT IGNORE and UPDATE IGNORE, '0000-00-00' is permitted and inserts produce a warning. As of MySQL 5.6.17, NO_ZERO_DATE is deprecated and setting the sql_mode value to include it generates a warning. NO_ZERO_IN_DATE The NO_ZERO_IN_DATE mode affects whether the server permits dates in which the year part is nonzero but the month or day part is 0. (This mode affects dates such as '2010-00-01' or '2010-01-00', but not '0000-00-00'. To control whether the server permits '0000-00-00', use the NO_ZERO_DATE mode.) The effect of NO_ZERO_IN_DATE also depends on whether strict SQL mode is enabled. If this mode is not enabled, dates with zero parts are permitted and inserts produce no warning. If this mode is enabled, dates with zero parts are inserted as '0000-00-00' and produce a warning. If this mode and strict mode are enabled, dates with zero parts are not permitted and inserts produce an error, unless IGNORE is given as well. For INSERT IGNORE and UPDATE IGNORE, dates with zero parts are inserted as '0000-00-00' and produce a warning. As of MySQL 5.6.17, NO_ZERO_IN_DATE is deprecated and setting the sql_mode value to include it generates a warning. https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html Pour résoudre ça, il faut modifier la configuration de MySQL Sous Windows, c'est le my.ini Il contient sql-mode="STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE,NO_AUTO_CREATE_USER" Remplacé par : sql-mode="ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER" Ça va pas être simple de gérer ça partout... -- RealET