[CalendarServer-changes] [12367] twext/trunk/twext/enterprise/dal

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:18:33 PDT 2014


Revision: 12367
          http://trac.calendarserver.org//changeset/12367
Author:   cdaboo at apple.com
Date:     2014-01-16 18:41:24 -0800 (Thu, 16 Jan 2014)
Log Message:
-----------
Support SQL min().

Modified Paths:
--------------
    twext/trunk/twext/enterprise/dal/syntax.py
    twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py

Modified: twext/trunk/twext/enterprise/dal/syntax.py
===================================================================
--- twext/trunk/twext/enterprise/dal/syntax.py	2014-01-17 02:22:43 UTC (rev 12366)
+++ twext/trunk/twext/enterprise/dal/syntax.py	2014-01-17 02:41:24 UTC (rev 12367)
@@ -600,6 +600,7 @@
 Count = Function("count")
 Sum = Function("sum")
 Max = Function("max")
+Min = Function("min")
 Len = Function("character_length", "length")
 Upper = Function("upper")
 Lower = Function("lower")

Modified: twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py
===================================================================
--- twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py	2014-01-17 02:22:43 UTC (rev 12366)
+++ twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py	2014-01-17 02:41:24 UTC (rev 12367)
@@ -29,7 +29,7 @@
         raise SkipTest("addSQLToSchema is not available: {0}".format(e))
 from twext.enterprise.dal.syntax import (
     Select, Insert, Update, Delete, Lock, SQLFragment,
-    TableMismatch, Parameter, Max, Len, NotEnoughValues,
+    TableMismatch, Parameter, Max, Min, Len, NotEnoughValues,
     Savepoint, RollbackToSavepoint, ReleaseSavepoint, SavepointAction,
     Union, Intersect, Except, SetExpression, DALError,
     ResultAliasSyntax, Count, QueryGenerator, ALL_COLUMNS,
@@ -1019,6 +1019,17 @@
         )
 
 
+    def test_min(self):
+        """
+        L{Min}C{(column)} produces an object in the C{columns} clause that
+        renders the C{min} aggregate in SQL.
+        """
+        self.assertEquals(
+            Select([Min(self.schema.BOZ.QUX)], From=self.schema.BOZ).toSQL(),
+            SQLFragment("select min(QUX) from BOZ")
+        )
+
+
     def test_countAllCoumns(self):
         """
         L{Count}C{(ALL_COLUMNS)} produces an object in the C{columns} clause
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/73abee7a/attachment.html>


More information about the calendarserver-changes mailing list