use strict mode with mysql
|Reported by:||foxwhisper||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.3|
|Cc:||django2.20.orzelf@…, tocker@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||yes|
|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 (11)
comment:1 Changed 4 years ago by aaugustin
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed
comment:2 Changed 4 years ago by kmtracey
- Needs documentation set
- Triage Stage changed from Design decision needed to Accepted
comment:3 Changed 4 years ago by anonymous
- Summary changed from Patch database documentation to explain why using sql_mode=strict is important to Patch database documentation to explain why using MySQL's sql_mode=strict is important
- UI/UX unset
comment:5 Changed 22 months ago by brian@…
- Component changed from Documentation to Database layer (models, ORM)
- Summary changed from Patch database documentation to explain why using MySQL's sql_mode=strict is important to use strict mode with mysql