#17653: using id = 0 on get_or_create
-------------------------------------+-------------------------------------
Reporter: sylvain.lebon@… | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.3
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by akaariai):
* cc: anssi.kaariainen@… (added)
Comment:
You could do a check in model.base_save(): connection.validate_pk(val),
which should just raise an exception if the backend doesn't work with the
given value. So, if you try to save a model with id=0, you would get an
exception on MySQL on 0-valued PK value, and otherwise things would work
as expected. This change should be simple to implement and safe to use. I
don't think backwards compatibility for MySQL 0-valued PKs is worth
worrying about: the current behavior can be considered a bug.
Another option is to just skip this issue by saying this is a bug in
MySQL, not in Django. But as in this case it is pretty easy to prevent the
confusing behavior, then why not?
--
Ticket URL: <https://code.djangoproject.com/ticket/17653#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.