In Django 1.3, Query objects do not possess the as_sql method.
Let's fix that, by calling as_sql on the SQLCompiler class.

Signed-off-by: Lucas Meneghel Rodrigues <[email protected]>
---
 frontend/tko/models.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/frontend/tko/models.py b/frontend/tko/models.py
index 483eb13..9b0d408 100644
--- a/frontend/tko/models.py
+++ b/frontend/tko/models.py
@@ -24,7 +24,9 @@ class TempManager(model_logic.ExtendedManager):
 
 
     def _get_group_query_sql(self, query, group_by):
-        sql, params = query.query.as_sql()
+        compiler = query.query.get_compiler(using=query.db)
+        sql, params = compiler.as_sql()
+
 
         # insert GROUP BY clause into query
         group_fields = self._get_field_names(group_by, 
query.query.extra_select)
@@ -79,7 +81,8 @@ class TempManager(model_logic.ExtendedManager):
         group_fields = self._get_field_names(group_by, 
query.query.extra_select)
         query = query.order_by() # this can mess up the query and isn't needed
 
-        sql, params = query.query.as_sql()
+        compiler = query.query.get_compiler(using=query.db)
+        sql, params = compiler.as_sql()
         from_ = sql[sql.find(' FROM'):]
         return ('SELECT DISTINCT %s %s' % (','.join(group_fields),
                                                   from_),
-- 
1.7.5.2

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to