#16865: get_or_create defaults to _for_write even when it's just reading -------------------------------------+------------------------------------- Reporter: Rick van Hattem | Owner: nobody <Rick.van.Hattem@…> | Status: new Type: Bug | Version: 1.3 Component: Database layer | Resolution: (models, ORM) | Triage Stage: Accepted Severity: Normal | Needs documentation: 0 Keywords: | Patch needs improvement: 0 Has patch: 0 | UI/UX: 0 Needs tests: 0 | Easy pickings: 1 | -------------------------------------+-------------------------------------
Comment (by WoLpH): @calvinspealman: it is called '''get'''_or_create isn't it? All of the Django code that uses it makes the assumption that it is always available and just falls back to creating if it is indeed new. And as you can see in the code, it is implemented as such. It does a get with a fallback to create. In your case it would be a create with a fallback to get if you get an integrity error. @kmtracey: You are right, it all depends on your replication method which it why this code has been working flawlessly for me so far. Regardless, the current system definately breaks any kind of master slave setup which is just silly. Perhaps the current database routers need an extra method for that. Right now we have the `db_for_write` and `db_for_read` but in this case it might be useful to have a `db_for_realtime_read` or something. Assuming that the database which you write to is also the one you want to read from is not in all cases right. -- Ticket URL: <https://code.djangoproject.com/ticket/16865#comment:5> 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.