[CalendarServer-changes] [15094] twext/trunk/twext/enterprise/dal
source_changes at macosforge.org
source_changes at macosforge.org
Thu Sep 3 13:39:06 PDT 2015
Revision: 15094
http://trac.calendarserver.org//changeset/15094
Author: cdaboo at apple.com
Date: 2015-09-03 13:39:06 -0700 (Thu, 03 Sep 2015)
Log Message:
-----------
Support NullIf function.
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 2015-09-03 20:38:35 UTC (rev 15093)
+++ twext/trunk/twext/enterprise/dal/syntax.py 2015-09-03 20:39:06 UTC (rev 15094)
@@ -614,6 +614,7 @@
Upper = Function("upper")
Lower = Function("lower")
Coalesce = Function("coalesce")
+NullIf = Function("nullif")
_sqliteLastInsertRowID = Function("last_insert_rowid")
Modified: twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py
===================================================================
--- twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py 2015-09-03 20:38:35 UTC (rev 15093)
+++ twext/trunk/twext/enterprise/dal/test/test_sqlsyntax.py 2015-09-03 20:39:06 UTC (rev 15094)
@@ -33,7 +33,7 @@
Savepoint, RollbackToSavepoint, ReleaseSavepoint, SavepointAction,
Union, Intersect, Except, SetExpression, DALError,
ResultAliasSyntax, Count, QueryGenerator, ALL_COLUMNS,
- DatabaseLock, DatabaseUnlock, Not, Coalesce)
+ DatabaseLock, DatabaseUnlock, Not, Coalesce, NullIf)
from twext.enterprise.dal.syntax import FixedPlaceholder, NumericPlaceholder
from twext.enterprise.dal.syntax import Function
from twext.enterprise.dal.syntax import SchemaSyntax
@@ -1143,6 +1143,20 @@
)
+ def test_nullif(self):
+ """
+ L{Coalesce}C{(column)} produces an object in the C{columns} clause that
+ renders the C{coalesce} conditional in SQL.
+ """
+ self.assertEquals(
+ Select(
+ [NullIf(self.schema.BOZ.QUX, Constant(False))],
+ From=self.schema.BOZ,
+ ).toSQL(),
+ SQLFragment("select nullif(QUX, ?) from BOZ", [False])
+ )
+
+
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/20150903/75d681f1/attachment-0001.html>
More information about the calendarserver-changes
mailing list