]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- added distinct() method to SelectResults. generally should only make a difference
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 Feb 2007 23:26:37 +0000 (23:26 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 Feb 2007 23:26:37 +0000 (23:26 +0000)
  when using count().

CHANGES
lib/sqlalchemy/ext/selectresults.py
test/orm/eagertest3.py

diff --git a/CHANGES b/CHANGES
index bfd310a07e84a101bd7b51996be0159bad06baf5..e11af50b757e556fac304e8daab6c13a7b24a117 100644 (file)
--- a/CHANGES
+++ b/CHANGES
 - postgres:
   - better reflection of sequences for alternate-schema Tables [ticket:442]
   - sequences on a non-pk column will properly fire off on INSERT
-
+- ext:
+  - added distinct() method to SelectResults.  generally should only make a difference
+  when using count().
+  
 0.3.4
 - general:
   - global "insure"->"ensure" change. in US english "insure" is actually
index 3e7fa93c8705aa6838983c8d630a229016ac9da7..5ad961f0ad27c5ff75a79ee4eacc0e314eb1b82d 100644 (file)
@@ -89,6 +89,12 @@ class SelectResults(object):
         """apply an OFFSET to the query."""
         return self[offset:]
 
+    def distinct(self):
+        """applies a DISTINCT to the query"""
+        new = self.clone()
+        new._ops['distinct'] = True
+        return new
+        
     def list(self):
         """return the results represented by this SelectResults as a list.  
         
index 5b498c0c807055c51bf681094b3e675caed8d745..1db0298477ff568898f4734080f64c8a5f42032a 100644 (file)
@@ -318,7 +318,9 @@ class EagerTest4(testbase.ORMTest):
         filters = [q.join_to('employees'),
                    Employee.c.name.startswith('J')]
 
-        d = SelectResults(q, and_(*filters), ops=dict(distinct=True))
+        d = SelectResults(q)
+        d = d.join_to('employees').filter(Employee.c.name.startswith('J'))
+        d = d.distinct()
         d = d.order_by([desc(Department.c.name)])
         assert d.count() == 2
         assert d[0] is d2