- changed component to sql
backport distinct(*expr) to 0.6
Issue #2150
resolved
Backport of distinct(*expr) to 0.6
diff -r fb9aba2155be4da60a54b707f3b40dc2853a1e6d lib/sqlalchemy/sql/expression.py
--- a/lib/sqlalchemy/sql/expression.py Sat Apr 23 15:13:45 2011 -0400
+++ b/lib/sqlalchemy/sql/expression.py Tue Apr 26 17:25:26 2011 -0500
@@ -4267,12 +4267,19 @@
self.append_having(having)
@_generative
- def distinct(self):
+ def distinct(self, *expr):
"""return a new select() construct which will apply DISTINCT to its
columns clause.
"""
- self._distinct = True
+ if expr:
+ expr = [for e in expr](_literal_as_text(e))
+ if isinstance(self._distinct, list):
+ self._distinct = self._distinct + expr
+ else:
+ self._distinct = expr
+ else:
+ self._distinct = True
@_generative
def prefix_with(self, clause):
See #1069 for the original patch.
Also please consider adding the related patch for Query objects as well.
Comments (3)
-
repo owner -
repo owner - changed status to wontfix
enhancements are already starting to be targeted to 0.8 at this point.
-
repo owner - removed milestone
Removing milestone: 0.6.xx (automated comment)
- Log in to comment
this is the actual patch: 3f9a343d725eea883aba2145de4cbb7b84f9d08c
its in 0.7 because it deprecates several features, and greatly reorganizes how "distinct" is handled at all levels.
the patch above includes:
im not yet convinced 0.6 really needs a new feature backport of this size - 0.7.0 is due very soon.