Recommend using strict mode with MySQL
|Reported by:||Cal Leeming||Owned by:||nobody|
|Cc:||django2.20.orzelf@…, tocker@…, george@…||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently, MySQL doesn't restrict you from entering an integer larger than the maximum allowed. It will raise a warning, but this warning isn't caught by Django anywhere. This is one of those gotcha's, which you only really notice after you've lost some data, and can't recover it (or unless you happened to come across similar threads like this).
Although I'd love to see Django using sql_mode=strict by default, I doubt this will happen. So instead, can we add a section into the database documentation ( http://docs.djangoproject.com/en/dev/ref/databases/ ) which explains why you should use sql_mode=strict, along with how to do it ( which is explained in (http://code.djangoproject.com/ticket/15923#comment:10 by kmtracey ).
On a side note, there may also be other reasons why using sql_mode would be good or bad, so this would possibly have to be explored before this could be accepted?
If this is accepted, I'd be happy to submit the documentation patch.
Change History (16)
comment:2 Changed 6 years ago by
|Triage Stage:||Design decision needed → Accepted|
comment:3 Changed 6 years ago by
|Summary:||Patch database documentation to explain why using sql_mode=strict is important → Patch database documentation to explain why using MySQL's sql_mode=strict is important|
comment:5 Changed 3 years ago by
|Component:||Documentation → Database layer (models, ORM)|
|Summary:||Patch database documentation to explain why using MySQL's sql_mode=strict is important → use strict mode with mysql|
comment:13 Changed 12 months ago by
|Component:||Database layer (models, ORM) → Documentation|
|Summary:||use strict mode with mysql → Recommend using strict mode with MySQL|