On Sun, 2009-01-18 at 17:46 -0200, Ramiro Morales wrote:
[....]
> 
> or if you are using a recent trunk version (more recent than two weeks or so)
> you might want to try printing the output of:
> 
> <QuerySet instance>.as_sql()

Please don't recommend that one, it's very likely to change in the near
future (like, this week some time), as I'm becoming unhappy with the
name choice for the reasons given below.

I was trying to keep the internal code clean by not having to if-case
yet another method name.. The problem with the current method name is
that it leaks the "SQL" concept into QuerySets, which should, ideally,
be agnostic about what the storage method is. Unnecessarily leaky
abstraction and it's keeping me awake at night.

Every QuerySet that has some kind of backing store should have a "query"
attribute and, if it supports SQL, will have an as_sql() method. (The
previous sentence is written in a very future-proof fashion. It's
trivially true for Django at the moment.) The queryset.query.as_sql()
method is the best way to look at the generated SQL.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to