On Fri, Oct 2, 2009 at 7:35 PM, mrts <mrts.py...@gmail.com> wrote: > > Wishful thinking follows. > > It would be awesome if one could mix ordinary QuerySet methods > with raw() (or, rather, raw_extra(), see below for that).
While I can see what you're aiming at here, I'm not really a fan of the idea. Django's ORM is designed to make the simple cases really simple, but once you move beyond the basics, you really should be looking to use raw SQL. When you try to mash segments of raw SQL into Django's internal query representation, it's very easy to start breaking things. extra() is already really fragile when it comes to interacting with other query features. Increasing the complexity of the SQL segments that you can inject into a query isn't going to improve the situation. I'm in favor of raw() specifically because it is only trying to make the output of raw SQL statements a little more palatable. It's interesting to me specifically because it doesn't try to integrate with normal Django queries. It makes it easier to use raw SQL without increasing the complexity of the query engine. Rather than trying to work out how to cram a query into Django's ORM, we acknowledge that Django's ORM has strengths, but for complex cases, raw SQL is still the language of choice. I think there are some things that we might be able to do to make writing the raw SQL a little easier - for example, allowing string substitutions for common parts of the query: SELECT %(columns)s FROM %(db_table) ... but even these I could live without. The important part is to provide a better answer for users that have a query that exceeds the capabilities of Django's ORM. Yours, Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---