Author: Alex
Date: 2010-06-07 15:18:17 -0500 (Mon, 07 Jun 2010)
New Revision: 13334

Modified:
   django/branches/soc2010/query-refactor/django/db/models/query.py
   django/branches/soc2010/query-refactor/django/db/models/sql/compiler.py
   django/branches/soc2010/query-refactor/django/db/models/sql/query.py
Log:
[soc2010/query-refactor] Moved has_results (implementation of exists()) onto 
the compiler, where it belongs.

Modified: django/branches/soc2010/query-refactor/django/db/models/query.py
===================================================================
--- django/branches/soc2010/query-refactor/django/db/models/query.py    
2010-06-07 20:03:43 UTC (rev 13333)
+++ django/branches/soc2010/query-refactor/django/db/models/query.py    
2010-06-07 20:18:17 UTC (rev 13334)
@@ -493,7 +493,7 @@
 
     def exists(self):
         if self._result_cache is None:
-            return self.query.has_results(using=self.db)
+            return self.query.get_compiler(self.db).has_results()
         return bool(self._result_cache)
 
     ##################################################

Modified: 
django/branches/soc2010/query-refactor/django/db/models/sql/compiler.py
===================================================================
--- django/branches/soc2010/query-refactor/django/db/models/sql/compiler.py     
2010-06-07 20:03:43 UTC (rev 13333)
+++ django/branches/soc2010/query-refactor/django/db/models/sql/compiler.py     
2010-06-07 20:18:17 UTC (rev 13334)
@@ -662,6 +662,20 @@
         columns = {}
         self.query.deferred_to_data(columns, self.query.deferred_to_columns_cb)
         return columns
+    
+    def has_results(self):
+        q = self.query.clone()
+        q.add_extra({'a': 1}, None, None, None, None, None)
+        q.select = []
+        q.select_fields = []
+        q.default_cols = False
+        q.select_related = False
+        q.set_extra_mask(('a',))
+        q.set_aggregate_mask(())
+        q.clear_ordering(True)
+        q.set_limits(high=1)
+        compiler = q.get_compiler(using=self.using)
+        return bool(compiler.execute_sql(SINGLE))
 
     def results_iter(self):
         """

Modified: django/branches/soc2010/query-refactor/django/db/models/sql/query.py
===================================================================
--- django/branches/soc2010/query-refactor/django/db/models/sql/query.py        
2010-06-07 20:03:43 UTC (rev 13333)
+++ django/branches/soc2010/query-refactor/django/db/models/sql/query.py        
2010-06-07 20:18:17 UTC (rev 13334)
@@ -402,20 +402,6 @@
 
         return number
 
-    def has_results(self, using):
-        q = self.clone()
-        q.add_extra({'a': 1}, None, None, None, None, None)
-        q.select = []
-        q.select_fields = []
-        q.default_cols = False
-        q.select_related = False
-        q.set_extra_mask(('a',))
-        q.set_aggregate_mask(())
-        q.clear_ordering(True)
-        q.set_limits(high=1)
-        compiler = q.get_compiler(using=using)
-        return bool(compiler.execute_sql(SINGLE))
-
     def combine(self, rhs, connector):
         """
         Merge the 'rhs' query into the current one (with any 'rhs' effects

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

Reply via email to