#25265: DB Backend cannot specify query class. -------------------------------------+------------------------------------- Reporter: techdragon | Owner: nobody Type: New feature | Status: new Component: Database layer | Version: master (models, ORM) | Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by akaariai): Its also worth noting that there are three ways to implement nonsql backends: 1. Implement Compiler 2. Implement Query (and possibly Compiler) 3. Implement QuerySet (and possibly Query and Compiler) Currently implementing a different Compiler for nonsql backend is the suggested approach. In principle it should work. In practice, I don't know. I guess the biggest problem is that when doing this, the author is targeting an often changing internal API. I'm not sure implementing Query is that much better. The API for Query isn't public. How about implementing QuerySet itself? Now that iterator is separated from QuerySet, it isn't that much more work when compared to just implementing Query and/or Compiler. For .using() incompatibility - I think we should throw an error. And the default backend should be used to decide what is the default queryset type. So, if you have default db = mongodb, other = postgres, then User.objects.filter(foo=bar).using('other') should throw an error, but User.objects.using('other').filter(foo=bar) shouldn't. It is also worth noting that maybe the right answer is to use different *models* altogether - Django's default user, permission and groups system for example isn't a good design for non-relational databases. If you control the models, then you also control the default queryset type, and we don't have a problem to begin with. I guess I am +½ to manager .get_queryset() checking the query/queryset class from the default backend, with the idea that objects.using('other') will get you the other backend's query/queryset class. Finally, I think whatever we come up with here, we should present the solution on django-developers and ask for opinions. -- Ticket URL: <https://code.djangoproject.com/ticket/25265#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 unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.d717023ecb49012421290d754ef289e8%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.