[CalendarServer-changes] [9709] CalendarServer/trunk/twext/enterprise/dal
source_changes at macosforge.org
source_changes at macosforge.org
Tue Aug 14 15:20:32 PDT 2012
Revision: 9709
http://trac.macosforge.org/projects/calendarserver/changeset/9709
Author: cdaboo at apple.com
Date: 2012-08-14 15:20:32 -0700 (Tue, 14 Aug 2012)
Log Message:
-----------
Make sure Count(*) works properly.
Modified Paths:
--------------
CalendarServer/trunk/twext/enterprise/dal/syntax.py
CalendarServer/trunk/twext/enterprise/dal/test/test_sqlsyntax.py
Modified: CalendarServer/trunk/twext/enterprise/dal/syntax.py
===================================================================
--- CalendarServer/trunk/twext/enterprise/dal/syntax.py 2012-08-14 22:17:59 UTC (rev 9708)
+++ CalendarServer/trunk/twext/enterprise/dal/syntax.py 2012-08-14 22:20:32 UTC (rev 9709)
@@ -929,11 +929,14 @@
-class _AllColumns(object):
+class _AllColumns(NamedValue):
- def subSQL(self, queryGenerator, allTables):
- return SQLFragment('*')
+ def __init__(self):
+ self.name = "*"
+ def allColumns(self):
+ return []
+
ALL_COLUMNS = _AllColumns()
Modified: CalendarServer/trunk/twext/enterprise/dal/test/test_sqlsyntax.py
===================================================================
--- CalendarServer/trunk/twext/enterprise/dal/test/test_sqlsyntax.py 2012-08-14 22:17:59 UTC (rev 9708)
+++ CalendarServer/trunk/twext/enterprise/dal/test/test_sqlsyntax.py 2012-08-14 22:20:32 UTC (rev 9709)
@@ -25,7 +25,7 @@
TableMismatch, Parameter, Max, Len, NotEnoughValues,
Savepoint, RollbackToSavepoint, ReleaseSavepoint, SavepointAction,
Union, Intersect, Except, SetExpression, DALError,
- ResultAliasSyntax, Count, QueryGenerator)
+ ResultAliasSyntax, Count, QueryGenerator, ALL_COLUMNS)
from twext.enterprise.dal.syntax import FixedPlaceholder, NumericPlaceholder
from twext.enterprise.dal.syntax import Function
from twext.enterprise.dal.syntax import SchemaSyntax
@@ -831,6 +831,17 @@
"select max(QUX) from BOZ"))
+ def test_countAllCoumns(self):
+ """
+ L{Count}C{(ALL_COLUMNS)} produces an object in the 'columns' clause that
+ renders the 'count' in SQL.
+ """
+ self.assertEquals(
+ Select([Count(ALL_COLUMNS)], From=self.schema.BOZ).toSQL(),
+ SQLFragment(
+ "select count(*) from BOZ"))
+
+
def test_aggregateComparison(self):
"""
L{Max}C{(column) > constant} produces an object in the 'columns' clause
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120814/ca3aa38e/attachment.html>
More information about the calendarserver-changes
mailing list