#16767: get_or_create does not raise error even though i didn't give a primary key to it -------------------------------------+------------------------------------- Reporter: haandol | Owner: nobody Type: Bug | Status: new Milestone: | Component: Database layer Version: 1.3 | (models, ORM) Resolution: | Severity: Normal Triage Stage: Accepted | Keywords: model, Needs documentation: 0 | get_or_create Patch needs improvement: 0 | Has patch: 0 UI/UX: 0 | Needs tests: 0 | Easy pickings: 0 -------------------------------------+------------------------------------- Changes (by akaariai):
* cc: anssi.kaariainen@… (added) * stage: Unreviewed => Accepted Comment: I can see the bug here - the get_or_create will create a user with id = ''. That seems confusing. The reason is probably the treatment of None as empty string (not that I have actually verified this is the case). The same problem is with .save(), User(email='foo...@foo.net').save() will save a user with id = ''. In effect `CharField` has a default value of '', and I guess that for primary keys that is not the wanted behavior. -- Ticket URL: <https://code.djangoproject.com/ticket/16767#comment:2> 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 django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.